<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="robots" content="noindex">

	<title>File Application/Runtime/common~runtime.php | XY Server API alpha</title>

	<link rel="stylesheet" href="resources/style.css?e99947befd7bf673c6b43ff75e9e0f170c88a60e">

</head>

<body>
<div id="left">
	<div id="menu">
		<a href="index.html" title="Overview"><span>Overview</span></a>


		<div id="groups">
				<h3>Namespaces</h3>
			<ul>
				<li>
					<a href="namespace-Behavior.html">
						Behavior					</a>

						</li>
				<li>
					<a href="namespace-DatebaseSQL.html">
						DatebaseSQL					</a>

						</li>
				<li>
					<a href="namespace-Doc.html">
						Doc					</a>

						</li>
				<li>
					<a href="namespace-ErrorCode.html">
						ErrorCode					</a>

						</li>
				<li>
					<a href="namespace-Home.html">
						Home<span></span>
					</a>

						<ul>
				<li>
					<a href="namespace-Home.Controller.html">
						Controller					</a>

						</li>
				<li>
					<a href="namespace-Home.Model.html">
						Model					</a>

						</li>
							</ul></li>
				<li>
					<a href="namespace-None.html">
						None					</a>

						</li>
				<li>
					<a href="namespace-Think.html">
						Think					</a>

						</li>
			</ul>
		</div>

		<hr>


		<div id="elements">
			<h3>Classes</h3>
			<ul>
				<li><a href="class-AccountModelTest.html">AccountModelTest</a></li>
				<li><a href="class-BaseTest.html">BaseTest</a></li>
				<li><a href="class-Behavior.BuildLiteBehavior.html">Behavior\BuildLiteBehavior</a></li>
				<li><a href="class-Behavior.ContentReplaceBehavior.html">Behavior\ContentReplaceBehavior</a></li>
				<li><a href="class-Behavior.ParseTemplateBehavior.html">Behavior\ParseTemplateBehavior</a></li>
				<li><a href="class-ErrorCode.ErrorCode.html">ErrorCode\ErrorCode</a></li>
				<li><a href="class-Home.Controller.AccountController.html">Home\Controller\AccountController</a></li>
				<li><a href="class-Home.Controller.ApplyController.html">Home\Controller\ApplyController</a></li>
				<li><a href="class-Home.Controller.AuthController.html">Home\Controller\AuthController</a></li>
				<li><a href="class-Home.Controller.BaseController.html">Home\Controller\BaseController</a></li>
				<li><a href="class-Home.Controller.CarlicenseController.html">Home\Controller\CarlicenseController</a></li>
				<li><a href="class-Home.Controller.CompanyController.html">Home\Controller\CompanyController</a></li>
				<li><a href="class-Home.Controller.ConfigController.html">Home\Controller\ConfigController</a></li>
				<li><a href="class-Home.Controller.ContactController.html">Home\Controller\ContactController</a></li>
				<li><a href="class-Home.Controller.CusListController.html">Home\Controller\CusListController</a></li>
				<li><a href="class-Home.Controller.DepartmentController.html">Home\Controller\DepartmentController</a></li>
				<li><a href="class-Home.Controller.EmptyController.html">Home\Controller\EmptyController</a></li>
				<li><a href="class-Home.Controller.EverydaySummarySheetController.html">Home\Controller\EverydaySummarySheetController</a></li>
				<li><a href="class-Home.Controller.FaceRecController.html">Home\Controller\FaceRecController</a></li>
				<li><a href="class-Home.Controller.FeedbackController.html">Home\Controller\FeedbackController</a></li>
				<li><a href="class-Home.Controller.FinanceController.html">Home\Controller\FinanceController</a></li>
				<li><a href="class-Home.Controller.GeneratorController.html">Home\Controller\GeneratorController</a></li>
				<li><a href="class-Home.Controller.GoodController.html">Home\Controller\GoodController</a></li>
				<li><a href="class-Home.Controller.HomeController.html">Home\Controller\HomeController</a></li>
				<li><a href="class-Home.Controller.IndexController.html" class="invalid">Home\Controller\IndexController</a></li>
				<li><a href="class-Home.Controller.InstallController.html">Home\Controller\InstallController</a></li>
				<li><a href="class-Home.Controller.LoginController.html">Home\Controller\LoginController</a></li>
				<li><a href="class-Home.Controller.OrderController.html">Home\Controller\OrderController</a></li>
				<li><a href="class-Home.Controller.OtherController.html">Home\Controller\OtherController</a></li>
				<li><a href="class-Home.Controller.ParkaddressController.html">Home\Controller\ParkaddressController</a></li>
				<li><a href="class-Home.Controller.PaybillController.html">Home\Controller\PaybillController</a></li>
				<li><a href="class-Home.Controller.PaymentDetailsController.html">Home\Controller\PaymentDetailsController</a></li>
				<li><a href="class-Home.Controller.PhonenumController.html">Home\Controller\PhonenumController</a></li>
				<li><a href="class-Home.Controller.PrintTemplateController.html">Home\Controller\PrintTemplateController</a></li>
				<li><a href="class-Home.Controller.QnUploadController.html">Home\Controller\QnUploadController</a></li>
				<li><a href="class-Home.Controller.QueryController.html">Home\Controller\QueryController</a></li>
				<li><a href="class-Home.Controller.RealDataGeneratorController.html">Home\Controller\RealDataGeneratorController</a></li>
				<li><a href="class-Home.Controller.SkuStorageController.html">Home\Controller\SkuStorageController</a></li>
				<li><a href="class-Home.Controller.SmsDetailsController.html">Home\Controller\SmsDetailsController</a></li>
				<li><a href="class-Home.Controller.StatementOfAccountController.html">Home\Controller\StatementOfAccountController</a></li>
				<li><a href="class-Home.Controller.StorageController.html">Home\Controller\StorageController</a></li>
				<li><a href="class-Home.Controller.UpdateController.html">Home\Controller\UpdateController</a></li>
				<li><a href="class-Home.Controller.UpdateDatabaseFormatController.html">Home\Controller\UpdateDatabaseFormatController</a></li>
				<li><a href="class-Home.Controller.UserAccountController.html">Home\Controller\UserAccountController</a></li>
				<li><a href="class-Home.Controller.UserController.html">Home\Controller\UserController</a></li>
				<li><a href="class-Home.Controller.UtilController.html">Home\Controller\UtilController</a></li>
				<li><a href="class-Home.Controller.WarehouseController.html">Home\Controller\WarehouseController</a></li>
				<li><a href="class-Home.Model.AccountModel.html">Home\Model\AccountModel</a></li>
				<li><a href="class-Home.Model.ApplyModel.html">Home\Model\ApplyModel</a></li>
				<li><a href="class-Home.Model.AsynTasksModel.html">Home\Model\AsynTasksModel</a></li>
				<li><a href="class-Home.Model.AuthGroupAccessModel.html">Home\Model\AuthGroupAccessModel</a></li>
				<li><a href="class-Home.Model.AuthGroupModel.html">Home\Model\AuthGroupModel</a></li>
				<li><a href="class-Home.Model.AuthRuleModel.html">Home\Model\AuthRuleModel</a></li>
				<li><a href="class-Home.Model.BaseadvModel.html">Home\Model\BaseadvModel</a></li>
				<li><a href="class-Home.Model.CarlicenseModel.html">Home\Model\CarlicenseModel</a></li>
				<li><a href="class-Home.Model.CatModel.html">Home\Model\CatModel</a></li>
				<li><a href="class-Home.Model.CompanyModel.html">Home\Model\CompanyModel</a></li>
				<li><a href="class-Home.Model.ConfigModel.html">Home\Model\ConfigModel</a></li>
				<li><a href="class-Home.Model.ContactModel.html">Home\Model\ContactModel</a></li>
				<li><a href="class-Home.Model.CusListModel.html">Home\Model\CusListModel</a></li>
				<li><a href="class-Home.Model.DepartmentModel.html">Home\Model\DepartmentModel</a></li>
				<li><a href="class-Home.Model.EverydaySummarySheetModel.html">Home\Model\EverydaySummarySheetModel</a></li>
				<li><a href="class-Home.Model.FaceRecModel.html">Home\Model\FaceRecModel</a></li>
				<li><a href="class-Home.Model.FeedbackModel.html">Home\Model\FeedbackModel</a></li>
				<li><a href="class-Home.Model.FinanceModel.html">Home\Model\FinanceModel</a></li>
				<li><a href="class-Home.Model.GoodModel.html">Home\Model\GoodModel</a></li>
				<li><a href="class-Home.Model.OrderModel.html">Home\Model\OrderModel</a></li>
				<li><a href="class-Home.Model.OtherModel.html">Home\Model\OtherModel</a></li>
				<li><a href="class-Home.Model.ParkaddressModel.html">Home\Model\ParkaddressModel</a></li>
				<li><a href="class-Home.Model.PaybillModel.html">Home\Model\PaybillModel</a></li>
				<li><a href="class-Home.Model.PaymentDetailsModel.html">Home\Model\PaymentDetailsModel</a></li>
				<li><a href="class-Home.Model.PhonenumModel.html">Home\Model\PhonenumModel</a></li>
				<li><a href="class-Home.Model.PinYin.html">Home\Model\PinYin</a></li>
				<li><a href="class-Home.Model.PrintTemplateModel.html">Home\Model\PrintTemplateModel</a></li>
				<li><a href="class-Home.Model.QnUploadModel.html">Home\Model\QnUploadModel</a></li>
				<li><a href="class-Home.Model.QueryModel.html">Home\Model\QueryModel</a></li>
				<li><a href="class-Home.Model.SkuBillModel.html">Home\Model\SkuBillModel</a></li>
				<li><a href="class-Home.Model.SkuCidPriceModel.html">Home\Model\SkuCidPriceModel</a></li>
				<li><a href="class-Home.Model.SkuModel.html">Home\Model\SkuModel</a></li>
				<li><a href="class-Home.Model.SkuStorageModel.html">Home\Model\SkuStorageModel</a></li>
				<li><a href="class-Home.Model.SmsDetailsModel.html">Home\Model\SmsDetailsModel</a></li>
				<li><a href="class-Home.Model.SpuModel.html">Home\Model\SpuModel</a></li>
				<li><a href="class-Home.Model.StatementAccountModel.html">Home\Model\StatementAccountModel</a></li>
				<li><a href="class-Home.Model.StorageModel.html">Home\Model\StorageModel</a></li>
				<li><a href="class-Home.Model.UpdateDatabaseFormatModel.html">Home\Model\UpdateDatabaseFormatModel</a></li>
				<li><a href="class-Home.Model.UserAccountModel.html">Home\Model\UserAccountModel</a></li>
				<li><a href="class-Home.Model.UserModel.html">Home\Model\UserModel</a></li>
				<li><a href="class-Home.Model.UtilModel.html">Home\Model\UtilModel</a></li>
				<li><a href="class-Home.Model.WarehouseModel.html">Home\Model\WarehouseModel</a></li>
				<li><a href="class-IndexTest.html" class="invalid">IndexTest</a></li>
				<li><a href="class-OrderTest.html">OrderTest</a></li>
				<li><a href="class-SkuTest.html" class="invalid">SkuTest</a></li>
				<li><a href="class-StorageTest.html">StorageTest</a></li>
				<li><a href="class-Think.App.html">Think\App</a></li>
				<li><a href="class-Think.Controller.html">Think\Controller</a></li>
				<li><a href="class-Think.Dispatcher.html">Think\Dispatcher</a></li>
				<li><a href="class-Think.Hook.html">Think\Hook</a></li>
				<li><a href="class-Think.Route.html">Think\Route</a></li>
				<li><a href="class-Think.View.html">Think\View</a></li>
				<li><a href="class-tpunit.html">tpunit</a></li>
				<li><a href="class-WarehouseTest.html">WarehouseTest</a></li>
			</ul>



			<h3>Exceptions</h3>
			<ul>
				<li><a href="class-XYException.html">XYException</a></li>
			</ul>


			<h3>Functions</h3>
			<ul>
				<li><a href="function-A.html">A</a></li>
				<li><a href="function-array_map_recursive.html">array_map_recursive</a></li>
				<li><a href="function-B.html">B</a></li>
				<li><a href="function-C.html">C</a></li>
				<li><a href="function-compile.html">compile</a></li>
				<li><a href="function-controller.html">controller</a></li>
				<li><a href="function-cookie.html">cookie</a></li>
				<li><a href="function-D.html">D</a></li>
				<li><a href="function-data_auth_sign.html">data_auth_sign</a></li>
				<li><a href="function-data_to_xml.html">data_to_xml</a></li>
				<li><a href="function-DatebaseSQL.datebaseSQL.html">DatebaseSQL\datebaseSQL</a></li>
				<li><a href="function-Doc.doc_view.html">Doc\doc_view</a></li>
				<li><a href="function-dump.html">dump</a></li>
				<li><a href="function-E.html">E</a></li>
				<li><a href="function-F.html">F</a></li>
				<li><a href="function-file_exists_case.html">file_exists_case</a></li>
				<li><a href="function-findSubStr.html">findSubStr</a></li>
				<li><a href="function-G.html">G</a></li>
				<li><a href="function-get_client_ip.html">get_client_ip</a></li>
				<li><a href="function-getAdminUid.html">getAdminUid</a></li>
				<li><a href="function-getLenOfDeciNum.html">getLenOfDeciNum</a></li>
				<li><a href="function-getRpg.html">getRpg</a></li>
				<li><a href="function-getUid.html">getUid</a></li>
				<li><a href="function-guid.html">guid</a></li>
				<li><a href="function-I.html">I</a></li>
				<li><a href="function-import.html">import</a></li>
				<li><a href="function-in_array_case.html">in_array_case</a></li>
				<li><a href="function-is_login.html">is_login</a></li>
				<li><a href="function-is_ssl.html">is_ssl</a></li>
				<li><a href="function-isInt.html">isInt</a></li>
				<li><a href="function-isLegalCurrency.html">isLegalCurrency</a></li>
				<li><a href="function-isNonegativeReal.html">isNonegativeReal</a></li>
				<li><a href="function-isNonnegativeInt.html">isNonnegativeInt</a></li>
				<li><a href="function-isPositiveReal.html">isPositiveReal</a></li>
				<li><a href="function-isUnsignedInt.html">isUnsignedInt</a></li>
				<li><a href="function-L.html">L</a></li>
				<li><a href="function-layout.html">layout</a></li>
				<li><a href="function-load.html">load</a></li>
				<li><a href="function-load_config.html">load_config</a></li>
				<li><a href="function-load_ext_file.html">load_ext_file</a></li>
				<li><a href="function-loadConfig.html">loadConfig</a></li>
				<li><a href="function-loadConfig_key.html">loadConfig_key</a></li>
				<li><a href="function-loadConfigFile.html">loadConfigFile</a></li>
				<li><a href="function-loadLocalConfig.html">loadLocalConfig</a></li>
				<li><a href="function-log_.html">log_</a></li>
				<li><a href="function-M.html">M</a></li>
				<li><a href="function-N.html">N</a></li>
				<li><a href="function-parse_name.html">parse_name</a></li>
				<li><a href="function-parse_res_name.html">parse_res_name</a></li>
				<li><a href="function-R.html">R</a></li>
				<li><a href="function-redirect.html">redirect</a></li>
				<li><a href="function-require_cache.html">require_cache</a></li>
				<li><a href="function-S.html">S</a></li>
				<li><a href="function-send_http_status.html">send_http_status</a></li>
				<li><a href="function-session.html">session</a></li>
				<li><a href="function-strip_whitespace.html">strip_whitespace</a></li>
				<li><a href="function-T.html">T</a></li>
				<li><a href="function-tag.html">tag</a></li>
				<li><a href="function-think_filter.html">think_filter</a></li>
				<li><a href="function-think_ucenter_decrypt.html">think_ucenter_decrypt</a></li>
				<li><a href="function-think_ucenter_encrypt.html">think_ucenter_encrypt</a></li>
				<li><a href="function-think_ucenter_md5.html">think_ucenter_md5</a></li>
				<li><a href="function-throw_exception.html">throw_exception</a></li>
				<li><a href="function-to_guid_string.html">to_guid_string</a></li>
				<li><a href="function-trace.html">trace</a></li>
				<li><a href="function-U.html">U</a></li>
				<li><a href="function-vendor.html">vendor</a></li>
				<li><a href="function-W.html">W</a></li>
				<li><a href="function-xml_encode.html">xml_encode</a></li>
				<li><a href="function-xyadd.html">xyadd</a></li>
				<li><a href="function-xycomp.html">xycomp</a></li>
				<li><a href="function-xydiv.html">xydiv</a></li>
				<li><a href="function-xymod.html">xymod</a></li>
				<li><a href="function-xymul.html">xymul</a></li>
				<li><a href="function-xyround.html">xyround</a></li>
				<li><a href="function-xysub.html">xysub</a></li>
				<li><a href="function-yaml_parse_file.html">yaml_parse_file</a></li>
			</ul>
		</div>
	</div>
</div>

<div id="splitter"></div>

<div id="right">
<div id="rightInner">
	<form id="search">
		<input type="hidden" name="cx" value="">
		<input type="hidden" name="ie" value="UTF-8">
		<input type="text" name="q" class="text" placeholder="Search">
	</form>

	<div id="navigation">
		<ul>
			<li>
				<a href="index.html" title="Overview"><span>Overview</span></a>
			</li>
			<li>
<span>Namespace</span>			</li>
			<li>
<span>Class</span>			</li>
		</ul>
		<ul>
			<li>
				<a href="tree.html" title="Tree view of classes, interfaces, traits and exceptions"><span>Tree</span></a>
			</li>
				<li>
					<a href="annotation-group-api.html" title="List of elements with api annotation">
						<span>Api</span>
					</a>
				</li>
				<li>
					<a href="annotation-group-version.html" title="List of elements with version annotation">
						<span>Version</span>
					</a>
				</li>
				<li>
					<a href="annotation-group-since.html" title="List of elements with since annotation">
						<span>Since</span>
					</a>
				</li>
				<li>
					<a href="annotation-group-deprecated.html" title="List of elements with deprecated annotation">
						<span>Deprecated</span>
					</a>
				</li>
				<li>
					<a href="annotation-group-todo.html" title="List of elements with todo annotation">
						<span>Todo</span>
					</a>
				</li>
		</ul>
		<ul>
		</ul>
	</div>

<pre><code><span id="1" class="l"><a href="#1">1: </a><span class="xlang">&lt;?php</span> <span class="php-keyword1">namespace</span> {<span class="php-keyword1">function</span> C(<span class="php-var">$name</span>=<span class="php-keyword1">null</span>, <span class="php-var">$value</span>=<span class="php-keyword1">null</span>,<span class="php-var">$default</span>=<span class="php-keyword1">null</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_config</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$name</span>)) { <span class="php-keyword1">return</span> <span class="php-var">$_config</span>; } <span class="php-keyword1">if</span> (<span class="php-keyword2">is_string</span>(<span class="php-var">$name</span>)) { <span class="php-keyword1">if</span> (!<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>, <span class="php-quote">'.'</span>)) { <span class="php-var">$name</span> = <span class="php-keyword2">strtoupper</span>(<span class="php-var">$name</span>); <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_config</span>[<span class="php-var">$name</span>]) ? <span class="php-var">$_config</span>[<span class="php-var">$name</span>] : <span class="php-var">$default</span>; <span class="php-var">$_config</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-var">$name</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>, <span class="php-var">$name</span>); <span class="php-var">$name</span>[<span class="php-num">0</span>] = <span class="php-keyword2">strtoupper</span>(<span class="php-var">$name</span>[<span class="php-num">0</span>]); <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_config</span>[<span class="php-var">$name</span>[<span class="php-num">0</span>]][<span class="php-var">$name</span>[<span class="php-num">1</span>]]) ? <span class="php-var">$_config</span>[<span class="php-var">$name</span>[<span class="php-num">0</span>]][<span class="php-var">$name</span>[<span class="php-num">1</span>]] : <span class="php-var">$default</span>; <span class="php-var">$_config</span>[<span class="php-var">$name</span>[<span class="php-num">0</span>]][<span class="php-var">$name</span>[<span class="php-num">1</span>]] = <span class="php-var">$value</span>; <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">if</span> (<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)){ <span class="php-var">$_config</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_config</span>, <span class="php-keyword2">array_change_key_case</span>(<span class="php-var">$name</span>,CASE_UPPER)); <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> load_config(<span class="php-var">$file</span>,<span class="php-var">$parse</span>=CONF_PARSE){ <span class="php-var">$ext</span> = <span class="php-keyword2">pathinfo</span>(<span class="php-var">$file</span>,PATHINFO_EXTENSION); <span class="php-keyword1">switch</span>(<span class="php-var">$ext</span>){ <span class="php-keyword1">case</span> <span class="php-quote">'php'</span>: <span class="php-keyword1">return</span> <span class="php-keyword1">include</span> <span class="php-var">$file</span>; <span class="php-keyword1">case</span> <span class="php-quote">'ini'</span>: <span class="php-keyword1">return</span> <span class="php-keyword2">parse_ini_file</span>(<span class="php-var">$file</span>); <span class="php-keyword1">case</span> <span class="php-quote">'yaml'</span>: <span class="php-keyword1">return</span> yaml_parse_file(<span class="php-var">$file</span>); <span class="php-keyword1">case</span> <span class="php-quote">'xml'</span>: <span class="php-keyword1">return</span> (<span class="php-keyword1">array</span>)<span class="php-keyword2">simplexml_load_file</span>(<span class="php-var">$file</span>); <span class="php-keyword1">case</span> <span class="php-quote">'json'</span>: <span class="php-keyword1">return</span> <span class="php-keyword2">json_decode</span>(<span class="php-keyword2">file_get_contents</span>(<span class="php-var">$file</span>), <span class="php-keyword1">true</span>); <span class="php-keyword1">default</span>: <span class="php-keyword1">if</span>(<span class="php-keyword2">function_exists</span>(<span class="php-var">$parse</span>)){ <span class="php-keyword1">return</span> <span class="php-var">$parse</span>(<span class="php-var">$file</span>); }<span class="php-keyword1">else</span>{ E(L(<span class="php-quote">'_NOT_SUPPORT_'</span>).<span class="php-quote">':'</span>.<span class="php-var">$ext</span>); } } } <span class="php-keyword1">if</span> (!<span class="php-keyword2">function_exists</span>(<span class="php-quote">'yaml_parse_file'</span>)) { <span class="php-keyword1">function</span> yaml_parse_file(<span class="php-var">$file</span>) { vendor(<span class="php-quote">'spyc.Spyc'</span>); <span class="php-keyword1">return</span> Spyc::YAMLLoad(<span class="php-var">$file</span>); } } <span class="php-keyword1">function</span> E(<span class="php-var">$msg</span>, <span class="php-var">$code</span>=<span class="php-num">0</span>) { <span class="php-keyword1">throw</span> <span class="php-keyword1">new</span> Think\Exception(<span class="php-var">$msg</span>, <span class="php-var">$code</span>); } <span class="php-keyword1">function</span> G(<span class="php-var">$start</span>,<span class="php-var">$end</span>=<span class="php-quote">''</span>,<span class="php-var">$dec</span>=<span class="php-num">4</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_info</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">static</span> <span class="php-var">$_mem</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_float</span>(<span class="php-var">$end</span>)) { <span class="php-var">$_info</span>[<span class="php-var">$start</span>] = <span class="php-var">$end</span>; }<span class="php-keyword1">elseif</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$end</span>)){ <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$_info</span>[<span class="php-var">$end</span>])) <span class="php-var">$_info</span>[<span class="php-var">$end</span>] = <span class="php-keyword2">microtime</span>(<span class="php-keyword1">TRUE</span>); <span class="php-keyword1">if</span>(MEMORY_LIMIT_ON &amp;&amp; <span class="php-var">$dec</span>==<span class="php-quote">'m'</span>){ <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$_mem</span>[<span class="php-var">$end</span>])) <span class="php-var">$_mem</span>[<span class="php-var">$end</span>] = <span class="php-keyword2">memory_get_usage</span>(); <span class="php-keyword1">return</span> <span class="php-keyword2">number_format</span>((<span class="php-var">$_mem</span>[<span class="php-var">$end</span>]-<span class="php-var">$_mem</span>[<span class="php-var">$start</span>])/<span class="php-num">1024</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword2">number_format</span>((<span class="php-var">$_info</span>[<span class="php-var">$end</span>]-<span class="php-var">$_info</span>[<span class="php-var">$start</span>]),<span class="php-var">$dec</span>); } }<span class="php-keyword1">else</span>{ <span class="php-var">$_info</span>[<span class="php-var">$start</span>] = <span class="php-keyword2">microtime</span>(<span class="php-keyword1">TRUE</span>); <span class="php-keyword1">if</span>(MEMORY_LIMIT_ON) <span class="php-var">$_mem</span>[<span class="php-var">$start</span>] = <span class="php-keyword2">memory_get_usage</span>(); } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> L(<span class="php-var">$name</span>=<span class="php-keyword1">null</span>, <span class="php-var">$value</span>=<span class="php-keyword1">null</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_lang</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$name</span>)) <span class="php-keyword1">return</span> <span class="php-var">$_lang</span>; <span class="php-keyword1">if</span> (<span class="php-keyword2">is_string</span>(<span class="php-var">$name</span>)) { <span class="php-var">$name</span> = <span class="php-keyword2">strtoupper</span>(<span class="php-var">$name</span>); <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)){ <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_lang</span>[<span class="php-var">$name</span>]) ? <span class="php-var">$_lang</span>[<span class="php-var">$name</span>] : <span class="php-var">$name</span>; }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$value</span>)){ <span class="php-var">$replace</span> = <span class="php-keyword2">array_keys</span>(<span class="php-var">$value</span>); <span class="php-keyword1">foreach</span>(<span class="php-var">$replace</span> <span class="php-keyword1">as</span> &amp;<span class="php-var">$v</span>){ <span class="php-var">$v</span> = <span class="php-quote">'{$'</span>.<span class="php-var">$v</span>.<span class="php-quote">'}'</span>; } <span class="php-keyword1">return</span> <span class="php-keyword2">str_replace</span>(<span class="php-var">$replace</span>,<span class="php-var">$value</span>,<span class="php-keyword1">isset</span>(<span class="php-var">$_lang</span>[<span class="php-var">$name</span>]) ? <span class="php-var">$_lang</span>[<span class="php-var">$name</span>] : <span class="php-var">$name</span>); } <span class="php-var">$_lang</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">if</span> (<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)) <span class="php-var">$_lang</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_lang</span>, <span class="php-keyword2">array_change_key_case</span>(<span class="php-var">$name</span>, CASE_UPPER)); <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> trace(<span class="php-var">$value</span>=<span class="php-quote">'[think]'</span>,<span class="php-var">$label</span>=<span class="php-quote">''</span>,<span class="php-var">$level</span>=<span class="php-quote">'DEBUG'</span>,<span class="php-var">$record</span>=<span class="php-keyword1">false</span>) { <span class="php-keyword1">return</span> Think\Think::trace(<span class="php-var">$value</span>,<span class="php-var">$label</span>,<span class="php-var">$level</span>,<span class="php-var">$record</span>); } <span class="php-keyword1">function</span> compile(<span class="php-var">$filename</span>) { <span class="php-var">$content</span> = <span class="php-keyword2">php_strip_whitespace</span>(<span class="php-var">$filename</span>); <span class="php-var">$content</span> = <span class="php-keyword2">trim</span>(<span class="php-keyword2">substr</span>(<span class="php-var">$content</span>, <span class="php-num">5</span>)); <span class="php-var">$content</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/\/\/\[RUNTIME\](.*?)\/\/\[\/RUNTIME\]/s'</span>, <span class="php-quote">''</span>, <span class="php-var">$content</span>); <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$content</span>,<span class="php-quote">'namespace'</span>)){ <span class="php-var">$content</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/namespace\s(.*?);/'</span>,<span class="php-quote">'namespace \\1{'</span>,<span class="php-var">$content</span>,<span class="php-num">1</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$content</span> = <span class="php-quote">'namespace {'</span>.<span class="php-var">$content</span>; } <span class="php-keyword1">if</span> (<span class="php-quote">'?&gt;'</span> == <span class="php-keyword2">substr</span>(<span class="php-var">$content</span>, -<span class="php-num">2</span>)) <span class="php-var">$content</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$content</span>, <span class="php-num">0</span>, -<span class="php-num">2</span>); <span class="php-keyword1">return</span> <span class="php-var">$content</span>.<span class="php-quote">'}'</span>; } <span class="php-keyword1">function</span> T(<span class="php-var">$template</span>=<span class="php-quote">''</span>,<span class="php-var">$layer</span>=<span class="php-quote">''</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$template</span>,<span class="php-quote">'://'</span>)){ <span class="php-var">$template</span> = <span class="php-quote">'http://'</span>.<span class="php-keyword2">str_replace</span>(<span class="php-quote">':'</span>, <span class="php-quote">'/'</span>,<span class="php-var">$template</span>); } <span class="php-var">$info</span> = <span class="php-keyword2">parse_url</span>(<span class="php-var">$template</span>); <span class="php-var">$file</span> = <span class="php-var">$info</span>[<span class="php-quote">'host'</span>].(<span class="php-keyword1">isset</span>(<span class="php-var">$info</span>[<span class="php-quote">'path'</span>])?<span class="php-var">$info</span>[<span class="php-quote">'path'</span>]:<span class="php-quote">''</span>); <span class="php-var">$module</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$info</span>[<span class="php-quote">'user'</span>])?<span class="php-var">$info</span>[<span class="php-quote">'user'</span>].<span class="php-quote">'/'</span>:MODULE_NAME.<span class="php-quote">'/'</span>; <span class="php-var">$extend</span> = <span class="php-var">$info</span>[<span class="php-quote">'scheme'</span>]; <span class="php-var">$layer</span> = <span class="php-var">$layer</span>?<span class="php-var">$layer</span>:C(<span class="php-quote">'DEFAULT_V_LAYER'</span>); <span class="php-var">$auto</span> = C(<span class="php-quote">'AUTOLOAD_NAMESPACE'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$auto</span> &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$auto</span>[<span class="php-var">$extend</span>])){ <span class="php-var">$baseUrl</span> = <span class="php-var">$auto</span>[<span class="php-var">$extend</span>].<span class="php-var">$module</span>.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>; }<span class="php-keyword1">elseif</span>(C(<span class="php-quote">'VIEW_PATH'</span>)){ <span class="php-var">$baseUrl</span> = C(<span class="php-quote">'VIEW_PATH'</span>); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">defined</span>(<span class="php-quote">'TMPL_PATH'</span>)){ <span class="php-var">$baseUrl</span> = TMPL_PATH.<span class="php-var">$module</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$baseUrl</span> = APP_PATH.<span class="php-var">$module</span>.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>; } <span class="php-var">$theme</span> = <span class="php-keyword2">substr_count</span>(<span class="php-var">$file</span>,<span class="php-quote">'/'</span>)&lt;<span class="php-num">2</span> ? C(<span class="php-quote">'DEFAULT_THEME'</span>) : <span class="php-quote">''</span>; <span class="php-var">$depr</span> = C(<span class="php-quote">'TMPL_FILE_DEPR'</span>); <span class="php-keyword1">if</span>(<span class="php-quote">''</span> == <span class="php-var">$file</span>) { <span class="php-var">$file</span> = CONTROLLER_NAME . <span class="php-var">$depr</span> . ACTION_NAME; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$file</span>, <span class="php-quote">'/'</span>)){ <span class="php-var">$file</span> = CONTROLLER_NAME . <span class="php-var">$depr</span> . <span class="php-var">$file</span>; }<span class="php-keyword1">elseif</span>(<span class="php-quote">'/'</span> != <span class="php-var">$depr</span>){ <span class="php-var">$file</span> = <span class="php-keyword2">substr_count</span>(<span class="php-var">$file</span>,<span class="php-quote">'/'</span>)&gt;<span class="php-num">1</span> ? <span class="php-keyword2">substr_replace</span>(<span class="php-var">$file</span>,<span class="php-var">$depr</span>,<span class="php-keyword2">strrpos</span>(<span class="php-var">$file</span>,<span class="php-quote">'/'</span>),<span class="php-num">1</span>) : <span class="php-keyword2">str_replace</span>(<span class="php-quote">'/'</span>, <span class="php-var">$depr</span>, <span class="php-var">$file</span>); } <span class="php-keyword1">return</span> <span class="php-var">$baseUrl</span>.(<span class="php-var">$theme</span>?<span class="php-var">$theme</span>.<span class="php-quote">'/'</span>:<span class="php-quote">''</span>).<span class="php-var">$file</span>.C(<span class="php-quote">'TMPL_TEMPLATE_SUFFIX'</span>); } <span class="php-keyword1">function</span> I(<span class="php-var">$name</span>,<span class="php-var">$default</span>=<span class="php-quote">''</span>,<span class="php-var">$filter</span>=<span class="php-keyword1">null</span>,<span class="php-var">$datas</span>=<span class="php-keyword1">null</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_PUT</span> = <span class="php-keyword1">null</span>; <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'/'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name</span>,<span class="php-var">$type</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$name</span>,<span class="php-num">2</span>); }<span class="php-keyword1">elseif</span>(C(<span class="php-quote">'VAR_AUTO_STRING'</span>)){ <span class="php-var">$type</span> = <span class="php-quote">'s'</span>; } <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$method</span>,<span class="php-var">$name</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>,<span class="php-num">2</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$method</span> = <span class="php-quote">'param'</span>; } <span class="php-keyword1">switch</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$method</span>)) { <span class="php-keyword1">case</span> <span class="php-quote">'get'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_GET</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'post'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_POST</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'put'</span> : <span class="php-keyword1">if</span>(<span class="php-keyword2">is_null</span>(<span class="php-var">$_PUT</span>)){ <span class="php-keyword2">parse_str</span>(<span class="php-keyword2">file_get_contents</span>(<span class="php-quote">'php://input'</span>), <span class="php-var">$_PUT</span>); } <span class="php-var">$input</span> = <span class="php-var">$_PUT</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'param'</span> : <span class="php-keyword1">switch</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'REQUEST_METHOD'</span>]) { <span class="php-keyword1">case</span> <span class="php-quote">'POST'</span>: <span class="php-var">$input</span> = <span class="php-var">$_POST</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'PUT'</span>: <span class="php-keyword1">if</span>(<span class="php-keyword2">is_null</span>(<span class="php-var">$_PUT</span>)){ <span class="php-keyword2">parse_str</span>(<span class="php-keyword2">file_get_contents</span>(<span class="php-quote">'php://input'</span>), <span class="php-var">$_PUT</span>); } <span class="php-var">$input</span> = <span class="php-var">$_PUT</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">default</span>: <span class="php-var">$input</span> = <span class="php-var">$_GET</span>; } <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'path'</span> : <span class="php-var">$input</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>])){ <span class="php-var">$depr</span> = C(<span class="php-quote">'URL_PATHINFO_DEPR'</span>); <span class="php-var">$input</span> = <span class="php-keyword2">explode</span>(<span class="php-var">$depr</span>,<span class="php-keyword2">trim</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>],<span class="php-var">$depr</span>)); } <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'request'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_REQUEST</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'session'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_SESSION</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'cookie'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_COOKIE</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'server'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$_SERVER</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'globals'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$GLOBALS</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'data'</span> : <span class="php-var">$input</span> =&amp; <span class="php-var">$datas</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">default</span>: <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">if</span>(<span class="php-quote">''</span>==<span class="php-var">$name</span>) { <span class="php-var">$data</span> = <span class="php-var">$input</span>; <span class="php-var">$filters</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$filter</span>)?<span class="php-var">$filter</span>:C(<span class="php-quote">'DEFAULT_FILTER'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$filters</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$filters</span>)){ <span class="php-var">$filters</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,<span class="php-var">$filters</span>); } <span class="php-keyword1">foreach</span>(<span class="php-var">$filters</span> <span class="php-keyword1">as</span> <span class="php-var">$filter</span>){ <span class="php-var">$data</span> = array_map_recursive(<span class="php-var">$filter</span>,<span class="php-var">$data</span>); } } }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$input</span>[<span class="php-var">$name</span>])) { <span class="php-var">$data</span> = <span class="php-var">$input</span>[<span class="php-var">$name</span>]; <span class="php-var">$filters</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$filter</span>)?<span class="php-var">$filter</span>:C(<span class="php-quote">'DEFAULT_FILTER'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$filters</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$filters</span>)){ <span class="php-keyword1">if</span>(<span class="php-num">0</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$filters</span>,<span class="php-quote">'/'</span>)){ <span class="php-keyword1">if</span>(<span class="php-num">1</span> !== <span class="php-keyword2">preg_match</span>(<span class="php-var">$filters</span>,(string)<span class="php-var">$data</span>)){ <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$default</span>) ? <span class="php-var">$default</span> : <span class="php-keyword1">null</span>; } }<span class="php-keyword1">else</span>{ <span class="php-var">$filters</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,<span class="php-var">$filters</span>); } }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_int</span>(<span class="php-var">$filters</span>)){ <span class="php-var">$filters</span> = <span class="php-keyword1">array</span>(<span class="php-var">$filters</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$filters</span>)){ <span class="php-keyword1">foreach</span>(<span class="php-var">$filters</span> <span class="php-keyword1">as</span> <span class="php-var">$filter</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">function_exists</span>(<span class="php-var">$filter</span>)) { <span class="php-var">$data</span> = <span class="php-keyword2">is_array</span>(<span class="php-var">$data</span>) ? array_map_recursive(<span class="php-var">$filter</span>,<span class="php-var">$data</span>) : <span class="php-var">$filter</span>(<span class="php-var">$data</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$data</span> = <span class="php-keyword2">filter_var</span>(<span class="php-var">$data</span>,<span class="php-keyword2">is_int</span>(<span class="php-var">$filter</span>) ? <span class="php-var">$filter</span> : <span class="php-keyword2">filter_id</span>(<span class="php-var">$filter</span>)); <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> === <span class="php-var">$data</span>) { <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$default</span>) ? <span class="php-var">$default</span> : <span class="php-keyword1">null</span>; } } } } } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$type</span>)){ <span class="php-keyword1">switch</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$type</span>)){ <span class="php-keyword1">case</span> <span class="php-quote">'a'</span>: <span class="php-var">$data</span> = (<span class="php-keyword1">array</span>)<span class="php-var">$data</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'d'</span>: <span class="php-var">$data</span> = (int)<span class="php-var">$data</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'f'</span>: <span class="php-var">$data</span> = (float)<span class="php-var">$data</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'b'</span>: <span class="php-var">$data</span> = (boolean)<span class="php-var">$data</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'s'</span>: <span class="php-keyword1">default</span>: <span class="php-var">$data</span> = (string)<span class="php-var">$data</span>; } } }<span class="php-keyword1">else</span>{ <span class="php-var">$data</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$default</span>)?<span class="php-var">$default</span>:<span class="php-keyword1">null</span>; } <span class="php-keyword2">is_array</span>(<span class="php-var">$data</span>) &amp;&amp; <span class="php-keyword2">array_walk_recursive</span>(<span class="php-var">$data</span>,<span class="php-quote">'think_filter'</span>); <span class="php-keyword1">return</span> <span class="php-var">$data</span>; } <span class="php-keyword1">function</span> array_map_recursive(<span class="php-var">$filter</span>, <span class="php-var">$data</span>) { <span class="php-var">$result</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">foreach</span> (<span class="php-var">$data</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$val</span>) { <span class="php-var">$result</span>[<span class="php-var">$key</span>] = <span class="php-keyword2">is_array</span>(<span class="php-var">$val</span>) ? array_map_recursive(<span class="php-var">$filter</span>, <span class="php-var">$val</span>) : <span class="php-keyword2">call_user_func</span>(<span class="php-var">$filter</span>, <span class="php-var">$val</span>); } <span class="php-keyword1">return</span> <span class="php-var">$result</span>; } <span class="php-keyword1">function</span> N(<span class="php-var">$key</span>, <span class="php-var">$step</span>=<span class="php-num">0</span>,<span class="php-var">$save</span>=<span class="php-keyword1">false</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_num</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span> (!<span class="php-keyword1">isset</span>(<span class="php-var">$_num</span>[<span class="php-var">$key</span>])) { <span class="php-var">$_num</span>[<span class="php-var">$key</span>] = (<span class="php-keyword1">false</span> !== <span class="php-var">$save</span>)? S(<span class="php-quote">'N_'</span>.<span class="php-var">$key</span>) : <span class="php-num">0</span>; } <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$step</span>)){ <span class="php-keyword1">return</span> <span class="php-var">$_num</span>[<span class="php-var">$key</span>]; }<span class="php-keyword1">else</span>{ <span class="php-var">$_num</span>[<span class="php-var">$key</span>] = <span class="php-var">$_num</span>[<span class="php-var">$key</span>] + (int)<span class="php-var">$step</span>; } <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-var">$save</span>){ S(<span class="php-quote">'N_'</span>.<span class="php-var">$key</span>,<span class="php-var">$_num</span>[<span class="php-var">$key</span>],<span class="php-var">$save</span>); } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> parse_name(<span class="php-var">$name</span>, <span class="php-var">$type</span>=<span class="php-num">0</span>) { <span class="php-keyword1">if</span> (<span class="php-var">$type</span>) { <span class="php-keyword1">return</span> <span class="php-keyword2">ucfirst</span>(<span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/_([a-zA-Z])/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>){<span class="php-keyword1">return</span> <span class="php-keyword2">strtoupper</span>(<span class="php-var">$match</span>[<span class="php-num">1</span>]);}, <span class="php-var">$name</span>)); } <span class="php-keyword1">else</span> { <span class="php-keyword1">return</span> <span class="php-keyword2">strtolower</span>(<span class="php-keyword2">trim</span>(<span class="php-keyword2">preg_replace</span>(<span class="php-quote">&quot;/[A-Z]/&quot;</span>, <span class="php-quote">&quot;_\\0&quot;</span>, <span class="php-var">$name</span>), <span class="php-quote">&quot;_&quot;</span>)); } } <span class="php-keyword1">function</span> require_cache(<span class="php-var">$filename</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_importFiles</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span> (!<span class="php-keyword1">isset</span>(<span class="php-var">$_importFiles</span>[<span class="php-var">$filename</span>])) { <span class="php-keyword1">if</span> (file_exists_case(<span class="php-var">$filename</span>)) { <span class="php-keyword1">require</span> <span class="php-var">$filename</span>; <span class="php-var">$_importFiles</span>[<span class="php-var">$filename</span>] = <span class="php-keyword1">true</span>; } <span class="php-keyword1">else</span> { <span class="php-var">$_importFiles</span>[<span class="php-var">$filename</span>] = <span class="php-keyword1">false</span>; } } <span class="php-keyword1">return</span> <span class="php-var">$_importFiles</span>[<span class="php-var">$filename</span>]; } <span class="php-keyword1">function</span> file_exists_case(<span class="php-var">$filename</span>) { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_file</span>(<span class="php-var">$filename</span>)) { <span class="php-keyword1">if</span> (IS_WIN &amp;&amp; APP_DEBUG) { <span class="php-keyword1">if</span> (<span class="php-keyword2">basename</span>(<span class="php-keyword2">realpath</span>(<span class="php-var">$filename</span>)) != <span class="php-keyword2">basename</span>(<span class="php-var">$filename</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-keyword1">function</span> import(<span class="php-var">$class</span>, <span class="php-var">$baseUrl</span> = <span class="php-quote">''</span>, <span class="php-var">$ext</span>=EXT) { <span class="php-keyword1">static</span> <span class="php-var">$_file</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$class</span> = <span class="php-keyword2">str_replace</span>(<span class="php-keyword1">array</span>(<span class="php-quote">'.'</span>, <span class="php-quote">'#'</span>), <span class="php-keyword1">array</span>(<span class="php-quote">'/'</span>, <span class="php-quote">'.'</span>), <span class="php-var">$class</span>); <span class="php-keyword1">if</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_file</span>[<span class="php-var">$class</span> . <span class="php-var">$baseUrl</span>])) <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; <span class="php-keyword1">else</span> <span class="php-var">$_file</span>[<span class="php-var">$class</span> . <span class="php-var">$baseUrl</span>] = <span class="php-keyword1">true</span>; <span class="php-var">$class_strut</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>, <span class="php-var">$class</span>); <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$baseUrl</span>)) { <span class="php-keyword1">if</span> (<span class="php-quote">'@'</span> == <span class="php-var">$class_strut</span>[<span class="php-num">0</span>] || MODULE_NAME == <span class="php-var">$class_strut</span>[<span class="php-num">0</span>]) { <span class="php-var">$baseUrl</span> = MODULE_PATH; <span class="php-var">$class</span> = <span class="php-keyword2">substr_replace</span>(<span class="php-var">$class</span>, <span class="php-quote">''</span>, <span class="php-num">0</span>, <span class="php-keyword2">strlen</span>(<span class="php-var">$class_strut</span>[<span class="php-num">0</span>]) + <span class="php-num">1</span>); }<span class="php-keyword1">elseif</span> (<span class="php-quote">'Common'</span> == <span class="php-var">$class_strut</span>[<span class="php-num">0</span>]) { <span class="php-var">$baseUrl</span> = COMMON_PATH; <span class="php-var">$class</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$class</span>, <span class="php-num">7</span>); }<span class="php-keyword1">elseif</span> (<span class="php-keyword2">in_array</span>(<span class="php-var">$class_strut</span>[<span class="php-num">0</span>],<span class="php-keyword1">array</span>(<span class="php-quote">'Think'</span>,<span class="php-quote">'Org'</span>,<span class="php-quote">'Behavior'</span>,<span class="php-quote">'Com'</span>,<span class="php-quote">'Vendor'</span>)) || <span class="php-keyword2">is_dir</span>(LIB_PATH.<span class="php-var">$class_strut</span>[<span class="php-num">0</span>])) { <span class="php-var">$baseUrl</span> = LIB_PATH; }<span class="php-keyword1">else</span> { <span class="php-var">$baseUrl</span> = APP_PATH; } } <span class="php-keyword1">if</span> (<span class="php-keyword2">substr</span>(<span class="php-var">$baseUrl</span>, -<span class="php-num">1</span>) != <span class="php-quote">'/'</span>) <span class="php-var">$baseUrl</span> .= <span class="php-quote">'/'</span>; <span class="php-var">$classfile</span> = <span class="php-var">$baseUrl</span> . <span class="php-var">$class</span> . <span class="php-var">$ext</span>; <span class="php-keyword1">if</span> (!<span class="php-keyword2">class_exists</span>(<span class="php-keyword2">basename</span>(<span class="php-var">$class</span>),<span class="php-keyword1">false</span>)) { <span class="php-keyword1">return</span> require_cache(<span class="php-var">$classfile</span>); } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> load(<span class="php-var">$name</span>, <span class="php-var">$baseUrl</span>=<span class="php-quote">''</span>, <span class="php-var">$ext</span>=<span class="php-quote">'.php'</span>) { <span class="php-var">$name</span> = <span class="php-keyword2">str_replace</span>(<span class="php-keyword1">array</span>(<span class="php-quote">'.'</span>, <span class="php-quote">'#'</span>), <span class="php-keyword1">array</span>(<span class="php-quote">'/'</span>, <span class="php-quote">'.'</span>), <span class="php-var">$name</span>); <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$baseUrl</span>)) { <span class="php-keyword1">if</span> (<span class="php-num">0</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>, <span class="php-quote">'@/'</span>)) { <span class="php-var">$baseUrl</span> = MODULE_PATH.<span class="php-quote">'Common/'</span>; <span class="php-var">$name</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$name</span>, <span class="php-num">2</span>); } <span class="php-keyword1">else</span> { <span class="php-var">$array</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>, <span class="php-var">$name</span>); <span class="php-var">$baseUrl</span> = APP_PATH . <span class="php-keyword2">array_shift</span>(<span class="php-var">$array</span>).<span class="php-quote">'/Common/'</span>; <span class="php-var">$name</span> = <span class="php-keyword2">implode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$array</span>); } } <span class="php-keyword1">if</span> (<span class="php-keyword2">substr</span>(<span class="php-var">$baseUrl</span>, -<span class="php-num">1</span>) != <span class="php-quote">'/'</span>) <span class="php-var">$baseUrl</span> .= <span class="php-quote">'/'</span>; require_cache(<span class="php-var">$baseUrl</span> . <span class="php-var">$name</span> . <span class="php-var">$ext</span>); } <span class="php-keyword1">function</span> vendor(<span class="php-var">$class</span>, <span class="php-var">$baseUrl</span> = <span class="php-quote">''</span>, <span class="php-var">$ext</span>=<span class="php-quote">'.php'</span>) { <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$baseUrl</span>)) <span class="php-var">$baseUrl</span> = VENDOR_PATH; <span class="php-keyword1">return</span> import(<span class="php-var">$class</span>, <span class="php-var">$baseUrl</span>, <span class="php-var">$ext</span>); } <span class="php-keyword1">function</span> D(<span class="php-var">$name</span>=<span class="php-quote">''</span>,<span class="php-var">$layer</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$name</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">new</span> Think\Model; <span class="php-keyword1">static</span> <span class="php-var">$_model</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$layer</span> = <span class="php-var">$layer</span>? : C(<span class="php-quote">'DEFAULT_M_LAYER'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_model</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>])) <span class="php-keyword1">return</span> <span class="php-var">$_model</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>]; <span class="php-var">$class</span> = parse_res_name(<span class="php-var">$name</span>,<span class="php-var">$layer</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$class</span>)) { <span class="php-var">$model</span> = <span class="php-keyword1">new</span> <span class="php-var">$class</span>(<span class="php-keyword2">basename</span>(<span class="php-var">$name</span>)); }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'/'</span>)){ <span class="php-keyword1">if</span>(!C(<span class="php-quote">'APP_USE_NAMESPACE'</span>)){ import(<span class="php-quote">'Common/'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>.<span class="php-var">$class</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$class</span> = <span class="php-quote">'\\Common\\'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'\\'</span>.<span class="php-var">$name</span>.<span class="php-var">$layer</span>; } <span class="php-var">$model</span> = <span class="php-keyword2">class_exists</span>(<span class="php-var">$class</span>)? <span class="php-keyword1">new</span> <span class="php-var">$class</span>(<span class="php-var">$name</span>) : <span class="php-keyword1">new</span> Think\Model(<span class="php-var">$name</span>); }<span class="php-keyword1">else</span> { Think\<span class="php-keyword2">Log</span>::record(<span class="php-quote">'D方法实例化没找到模型类'</span>.<span class="php-var">$class</span>,Think\<span class="php-keyword2">Log</span>::NOTICE); <span class="php-var">$model</span> = <span class="php-keyword1">new</span> Think\Model(<span class="php-keyword2">basename</span>(<span class="php-var">$name</span>)); } <span class="php-var">$_model</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>] = <span class="php-var">$model</span>; <span class="php-keyword1">return</span> <span class="php-var">$model</span>; } <span class="php-keyword1">function</span> M(<span class="php-var">$name</span>=<span class="php-quote">''</span>, <span class="php-var">$tablePrefix</span>=<span class="php-quote">''</span>,<span class="php-var">$connection</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_model</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">':'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$class</span>,<span class="php-var">$name</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">':'</span>,<span class="php-var">$name</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$class</span> = <span class="php-quote">'Think\\Model'</span>; } <span class="php-var">$guid</span> = (<span class="php-keyword2">is_array</span>(<span class="php-var">$connection</span>)?<span class="php-keyword2">implode</span>(<span class="php-quote">''</span>,<span class="php-var">$connection</span>):<span class="php-var">$connection</span>).<span class="php-var">$tablePrefix</span> . <span class="php-var">$name</span> . <span class="php-quote">'_'</span> . <span class="php-var">$class</span>; <span class="php-keyword1">if</span> (!<span class="php-keyword1">isset</span>(<span class="php-var">$_model</span>[<span class="php-var">$guid</span>])) <span class="php-var">$_model</span>[<span class="php-var">$guid</span>] = <span class="php-keyword1">new</span> <span class="php-var">$class</span>(<span class="php-var">$name</span>,<span class="php-var">$tablePrefix</span>,<span class="php-var">$connection</span>); <span class="php-keyword1">return</span> <span class="php-var">$_model</span>[<span class="php-var">$guid</span>]; } <span class="php-keyword1">function</span> parse_res_name(<span class="php-var">$name</span>,<span class="php-var">$layer</span>,<span class="php-var">$level</span>=<span class="php-num">1</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'://'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$extend</span>,<span class="php-var">$name</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'://'</span>,<span class="php-var">$name</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$extend</span> = <span class="php-quote">''</span>; } <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'/'</span>) &amp;&amp; <span class="php-keyword2">substr_count</span>(<span class="php-var">$name</span>, <span class="php-quote">'/'</span>)&gt;=<span class="php-var">$level</span>){ <span class="php-keyword1">list</span>(<span class="php-var">$module</span>,<span class="php-var">$name</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$name</span>,<span class="php-num">2</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$module</span> = <span class="php-keyword2">defined</span>(<span class="php-quote">'MODULE_NAME'</span>) ? MODULE_NAME : <span class="php-quote">''</span> ; } <span class="php-var">$array</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">if</span>(!C(<span class="php-quote">'APP_USE_NAMESPACE'</span>)){ <span class="php-var">$class</span> = parse_name(<span class="php-var">$name</span>, <span class="php-num">1</span>); import(<span class="php-var">$module</span>.<span class="php-quote">'/'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>.<span class="php-var">$class</span>.<span class="php-var">$layer</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$class</span> = <span class="php-var">$module</span>.<span class="php-quote">'\\'</span>.<span class="php-var">$layer</span>; <span class="php-keyword1">foreach</span>(<span class="php-var">$array</span> <span class="php-keyword1">as</span> <span class="php-var">$name</span>){ <span class="php-var">$class</span> .= <span class="php-quote">'\\'</span>.parse_name(<span class="php-var">$name</span>, <span class="php-num">1</span>); } <span class="php-keyword1">if</span>(<span class="php-var">$extend</span>){ <span class="php-var">$class</span> = <span class="php-var">$extend</span>.<span class="php-quote">'\\'</span>.<span class="php-var">$class</span>; } } <span class="php-keyword1">return</span> <span class="php-var">$class</span>.<span class="php-var">$layer</span>; } <span class="php-keyword1">function</span> controller(<span class="php-var">$name</span>,<span class="php-var">$path</span>=<span class="php-quote">''</span>){ <span class="php-var">$layer</span> = C(<span class="php-quote">'DEFAULT_C_LAYER'</span>); <span class="php-keyword1">if</span>(!C(<span class="php-quote">'APP_USE_NAMESPACE'</span>)){ <span class="php-var">$class</span> = parse_name(<span class="php-var">$name</span>, <span class="php-num">1</span>).<span class="php-var">$layer</span>; import(MODULE_NAME.<span class="php-quote">'/'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>.<span class="php-var">$class</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$class</span> = ( <span class="php-var">$path</span> ? <span class="php-keyword2">basename</span>(ADDON_PATH).<span class="php-quote">'\\'</span>.<span class="php-var">$path</span> : MODULE_NAME ).<span class="php-quote">'\\'</span>.<span class="php-var">$layer</span>; <span class="php-var">$array</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">foreach</span>(<span class="php-var">$array</span> <span class="php-keyword1">as</span> <span class="php-var">$name</span>){ <span class="php-var">$class</span> .= <span class="php-quote">'\\'</span>.parse_name(<span class="php-var">$name</span>, <span class="php-num">1</span>); } <span class="php-var">$class</span> .= <span class="php-var">$layer</span>; } <span class="php-keyword1">if</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$class</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword1">new</span> <span class="php-var">$class</span>(); }<span class="php-keyword1">else</span> { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } <span class="php-keyword1">function</span> A(<span class="php-var">$name</span>,<span class="php-var">$layer</span>=<span class="php-quote">''</span>,<span class="php-var">$level</span>=<span class="php-num">0</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_action</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$layer</span> = <span class="php-var">$layer</span>? : C(<span class="php-quote">'DEFAULT_C_LAYER'</span>); <span class="php-var">$level</span> = <span class="php-var">$level</span>? : (<span class="php-var">$layer</span> == C(<span class="php-quote">'DEFAULT_C_LAYER'</span>)?C(<span class="php-quote">'CONTROLLER_LEVEL'</span>):<span class="php-num">1</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_action</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>])) <span class="php-keyword1">return</span> <span class="php-var">$_action</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>]; <span class="php-var">$class</span> = parse_res_name(<span class="php-var">$name</span>,<span class="php-var">$layer</span>,<span class="php-var">$level</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$class</span>)) { <span class="php-var">$action</span> = <span class="php-keyword1">new</span> <span class="php-var">$class</span>(); <span class="php-var">$_action</span>[<span class="php-var">$name</span>.<span class="php-var">$layer</span>] = <span class="php-var">$action</span>; <span class="php-keyword1">return</span> <span class="php-var">$action</span>; }<span class="php-keyword1">else</span> { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } <span class="php-keyword1">function</span> R(<span class="php-var">$url</span>,<span class="php-var">$vars</span>=<span class="php-keyword1">array</span>(),<span class="php-var">$layer</span>=<span class="php-quote">''</span>) { <span class="php-var">$info</span> = <span class="php-keyword2">pathinfo</span>(<span class="php-var">$url</span>); <span class="php-var">$action</span> = <span class="php-var">$info</span>[<span class="php-quote">'basename'</span>]; <span class="php-var">$module</span> = <span class="php-var">$info</span>[<span class="php-quote">'dirname'</span>]; <span class="php-var">$class</span> = A(<span class="php-var">$module</span>,<span class="php-var">$layer</span>); <span class="php-keyword1">if</span>(<span class="php-var">$class</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$vars</span>)) { <span class="php-keyword2">parse_str</span>(<span class="php-var">$vars</span>,<span class="php-var">$vars</span>); } <span class="php-keyword1">return</span> <span class="php-keyword2">call_user_func_array</span>(<span class="php-keyword1">array</span>(&amp;<span class="php-var">$class</span>,<span class="php-var">$action</span>.C(<span class="php-quote">'ACTION_SUFFIX'</span>)),<span class="php-var">$vars</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } <span class="php-keyword1">function</span> tag(<span class="php-var">$tag</span>, &amp;<span class="php-var">$params</span>=<span class="php-keyword1">NULL</span>) { \Think\Hook::listen(<span class="php-var">$tag</span>,<span class="php-var">$params</span>); } <span class="php-keyword1">function</span> B(<span class="php-var">$name</span>, <span class="php-var">$tag</span>=<span class="php-quote">''</span>,&amp;<span class="php-var">$params</span>=<span class="php-keyword1">NULL</span>) { <span class="php-keyword1">if</span>(<span class="php-quote">''</span>==<span class="php-var">$tag</span>){ <span class="php-var">$name</span> .= <span class="php-quote">'Behavior'</span>; } <span class="php-keyword1">return</span> \Think\Hook::<span class="php-keyword2">exec</span>(<span class="php-var">$name</span>,<span class="php-var">$tag</span>,<span class="php-var">$params</span>); } <span class="php-keyword1">function</span> strip_whitespace(<span class="php-var">$content</span>) { <span class="php-var">$stripStr</span> = <span class="php-quote">''</span>; <span class="php-var">$tokens</span> = <span class="php-keyword2">token_get_all</span>(<span class="php-var">$content</span>); <span class="php-var">$last_space</span> = <span class="php-keyword1">false</span>; <span class="php-keyword1">for</span> (<span class="php-var">$i</span> = <span class="php-num">0</span>, <span class="php-var">$j</span> = <span class="php-keyword2">count</span>(<span class="php-var">$tokens</span>); <span class="php-var">$i</span> &lt; <span class="php-var">$j</span>; <span class="php-var">$i</span>++) { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_string</span>(<span class="php-var">$tokens</span>[<span class="php-var">$i</span>])) { <span class="php-var">$last_space</span> = <span class="php-keyword1">false</span>; <span class="php-var">$stripStr</span> .= <span class="php-var">$tokens</span>[<span class="php-var">$i</span>]; } <span class="php-keyword1">else</span> { <span class="php-keyword1">switch</span> (<span class="php-var">$tokens</span>[<span class="php-var">$i</span>][<span class="php-num">0</span>]) { <span class="php-keyword1">case</span> T_COMMENT: <span class="php-keyword1">case</span> T_DOC_COMMENT: <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> T_WHITESPACE: <span class="php-keyword1">if</span> (!<span class="php-var">$last_space</span>) { <span class="php-var">$stripStr</span> .= <span class="php-quote">' '</span>; <span class="php-var">$last_space</span> = <span class="php-keyword1">true</span>; } <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> T_START_HEREDOC: <span class="php-var">$stripStr</span> .= <span class="php-quote">&quot;&lt;&lt;&lt;THINK\n&quot;</span>; <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> T_END_HEREDOC: <span class="php-var">$stripStr</span> .= <span class="php-quote">&quot;THINK;\n&quot;</span>; <span class="php-keyword1">for</span>(<span class="php-var">$k</span> = <span class="php-var">$i</span>+<span class="php-num">1</span>; <span class="php-var">$k</span> &lt; <span class="php-var">$j</span>; <span class="php-var">$k</span>++) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$tokens</span>[<span class="php-var">$k</span>]) &amp;&amp; <span class="php-var">$tokens</span>[<span class="php-var">$k</span>] == <span class="php-quote">';'</span>) { <span class="php-var">$i</span> = <span class="php-var">$k</span>; <span class="php-keyword1">break</span>; } <span class="php-keyword1">else</span> <span class="php-keyword1">if</span>(<span class="php-var">$tokens</span>[<span class="php-var">$k</span>][<span class="php-num">0</span>] == T_CLOSE_TAG) { <span class="php-keyword1">break</span>; } } <span class="php-keyword1">break</span>; <span class="php-keyword1">default</span>: <span class="php-var">$last_space</span> = <span class="php-keyword1">false</span>; <span class="php-var">$stripStr</span> .= <span class="php-var">$tokens</span>[<span class="php-var">$i</span>][<span class="php-num">1</span>]; } } } <span class="php-keyword1">return</span> <span class="php-var">$stripStr</span>; } <span class="php-keyword1">function</span> throw_exception(<span class="php-var">$msg</span>, <span class="php-var">$type</span>=<span class="php-quote">'Think\\Exception'</span>, <span class="php-var">$code</span>=<span class="php-num">0</span>) { Think\<span class="php-keyword2">Log</span>::record(<span class="php-quote">'建议使用E方法替代throw_exception'</span>,Think\<span class="php-keyword2">Log</span>::NOTICE); <span class="php-keyword1">if</span> (<span class="php-keyword2">class_exists</span>(<span class="php-var">$type</span>, <span class="php-keyword1">false</span>)) <span class="php-keyword1">throw</span> <span class="php-keyword1">new</span> <span class="php-var">$type</span>(<span class="php-var">$msg</span>, <span class="php-var">$code</span>); <span class="php-keyword1">else</span> Think\Think::halt(<span class="php-var">$msg</span>); } <span class="php-keyword1">function</span> dump(<span class="php-var">$var</span>, <span class="php-var">$echo</span>=<span class="php-keyword1">true</span>, <span class="php-var">$label</span>=<span class="php-keyword1">null</span>, <span class="php-var">$strict</span>=<span class="php-keyword1">true</span>) { <span class="php-var">$label</span> = (<span class="php-var">$label</span> === <span class="php-keyword1">null</span>) ? <span class="php-quote">''</span> : <span class="php-keyword2">rtrim</span>(<span class="php-var">$label</span>) . <span class="php-quote">' '</span>; <span class="php-keyword1">if</span> (!<span class="php-var">$strict</span>) { <span class="php-keyword1">if</span> (<span class="php-keyword2">ini_get</span>(<span class="php-quote">'html_errors'</span>)) { <span class="php-var">$output</span> = <span class="php-keyword2">print_r</span>(<span class="php-var">$var</span>, <span class="php-keyword1">true</span>); <span class="php-var">$output</span> = <span class="php-quote">'&lt;pre&gt;'</span> . <span class="php-var">$label</span> . <span class="php-keyword2">htmlspecialchars</span>(<span class="php-var">$output</span>, ENT_QUOTES) . <span class="php-quote">'&lt;/pre&gt;'</span>; } <span class="php-keyword1">else</span> { <span class="php-var">$output</span> = <span class="php-var">$label</span> . <span class="php-keyword2">print_r</span>(<span class="php-var">$var</span>, <span class="php-keyword1">true</span>); } } <span class="php-keyword1">else</span> { <span class="php-keyword2">ob_start</span>(); <span class="php-keyword2">var_dump</span>(<span class="php-var">$var</span>); <span class="php-var">$output</span> = <span class="php-keyword2">ob_get_clean</span>(); <span class="php-keyword1">if</span> (!<span class="php-keyword2">extension_loaded</span>(<span class="php-quote">'xdebug'</span>)) { <span class="php-var">$output</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/\]\=\&gt;\n(\s+)/m'</span>, <span class="php-quote">'] =&gt; '</span>, <span class="php-var">$output</span>); <span class="php-var">$output</span> = <span class="php-quote">'&lt;pre&gt;'</span> . <span class="php-var">$label</span> . <span class="php-keyword2">htmlspecialchars</span>(<span class="php-var">$output</span>, ENT_QUOTES) . <span class="php-quote">'&lt;/pre&gt;'</span>; } } <span class="php-keyword1">if</span> (<span class="php-var">$echo</span>) { <span class="php-keyword1">echo</span>(<span class="php-var">$output</span>); <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; }<span class="php-keyword1">else</span> <span class="php-keyword1">return</span> <span class="php-var">$output</span>; } <span class="php-keyword1">function</span> layout(<span class="php-var">$layout</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-var">$layout</span>) { C(<span class="php-quote">'LAYOUT_ON'</span>,<span class="php-keyword1">true</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$layout</span>)) { C(<span class="php-quote">'LAYOUT_NAME'</span>,<span class="php-var">$layout</span>); } }<span class="php-keyword1">else</span>{ C(<span class="php-quote">'LAYOUT_ON'</span>,<span class="php-keyword1">false</span>); } } <span class="php-keyword1">function</span> U(<span class="php-var">$url</span>=<span class="php-quote">''</span>,<span class="php-var">$vars</span>=<span class="php-quote">''</span>,<span class="php-var">$suffix</span>=<span class="php-keyword1">true</span>,<span class="php-var">$domain</span>=<span class="php-keyword1">false</span>) { <span class="php-var">$info</span> = <span class="php-keyword2">parse_url</span>(<span class="php-var">$url</span>); <span class="php-var">$url</span> = !<span class="php-keyword1">empty</span>(<span class="php-var">$info</span>[<span class="php-quote">'path'</span>])?<span class="php-var">$info</span>[<span class="php-quote">'path'</span>]:ACTION_NAME; <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$info</span>[<span class="php-quote">'fragment'</span>])) { <span class="php-var">$anchor</span> = <span class="php-var">$info</span>[<span class="php-quote">'fragment'</span>]; <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-keyword2">strpos</span>(<span class="php-var">$anchor</span>,<span class="php-quote">'?'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$anchor</span>,<span class="php-var">$info</span>[<span class="php-quote">'query'</span>]) = <span class="php-keyword2">explode</span>(<span class="php-quote">'?'</span>,<span class="php-var">$anchor</span>,<span class="php-num">2</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-keyword2">strpos</span>(<span class="php-var">$anchor</span>,<span class="php-quote">'@'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$anchor</span>,<span class="php-var">$host</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'@'</span>,<span class="php-var">$anchor</span>, <span class="php-num">2</span>); } }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">false</span> !== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'@'</span>)) { <span class="php-keyword1">list</span>(<span class="php-var">$url</span>,<span class="php-var">$host</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'@'</span>,<span class="php-var">$info</span>[<span class="php-quote">'path'</span>], <span class="php-num">2</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$host</span>)) { <span class="php-var">$domain</span> = <span class="php-var">$host</span>.(<span class="php-keyword2">strpos</span>(<span class="php-var">$host</span>,<span class="php-quote">'.'</span>)?<span class="php-quote">''</span>:<span class="php-keyword2">strstr</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>],<span class="php-quote">'.'</span>)); }<span class="php-keyword1">elseif</span>(<span class="php-var">$domain</span>===<span class="php-keyword1">true</span>){ <span class="php-var">$domain</span> = <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>]; <span class="php-keyword1">if</span>(C(<span class="php-quote">'APP_SUB_DOMAIN_DEPLOY'</span>) ) { <span class="php-var">$domain</span> = <span class="php-var">$domain</span>==<span class="php-quote">'localhost'</span>?<span class="php-quote">'localhost'</span>:<span class="php-quote">'www'</span>.<span class="php-keyword2">strstr</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>],<span class="php-quote">'.'</span>); <span class="php-keyword1">foreach</span> (C(<span class="php-quote">'APP_SUB_DOMAIN_RULES'</span>) <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$rule</span>) { <span class="php-var">$rule</span> = <span class="php-keyword2">is_array</span>(<span class="php-var">$rule</span>)?<span class="php-var">$rule</span>[<span class="php-num">0</span>]:<span class="php-var">$rule</span>; <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$key</span>,<span class="php-quote">'*'</span>) &amp;&amp; <span class="php-num">0</span>=== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-var">$rule</span>)) { <span class="php-var">$domain</span> = <span class="php-var">$key</span>.<span class="php-keyword2">strstr</span>(<span class="php-var">$domain</span>,<span class="php-quote">'.'</span>); <span class="php-var">$url</span> = <span class="php-keyword2">substr_replace</span>(<span class="php-var">$url</span>,<span class="php-quote">''</span>,<span class="php-num">0</span>,<span class="php-keyword2">strlen</span>(<span class="php-var">$rule</span>)); <span class="php-keyword1">break</span>; } } } } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$vars</span>)) { <span class="php-keyword2">parse_str</span>(<span class="php-var">$vars</span>,<span class="php-var">$vars</span>); }<span class="php-keyword1">elseif</span>(!<span class="php-keyword2">is_array</span>(<span class="php-var">$vars</span>)){ <span class="php-var">$vars</span> = <span class="php-keyword1">array</span>(); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$info</span>[<span class="php-quote">'query'</span>])) { <span class="php-keyword2">parse_str</span>(<span class="php-var">$info</span>[<span class="php-quote">'query'</span>],<span class="php-var">$params</span>); <span class="php-var">$vars</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$params</span>,<span class="php-var">$vars</span>); } <span class="php-var">$depr</span> = C(<span class="php-quote">'URL_PATHINFO_DEPR'</span>); <span class="php-var">$urlCase</span> = C(<span class="php-quote">'URL_CASE_INSENSITIVE'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$url</span>) { <span class="php-keyword1">if</span>(<span class="php-num">0</span>=== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'/'</span>)) { <span class="php-var">$route</span> = <span class="php-keyword1">true</span>; <span class="php-var">$url</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$url</span>,<span class="php-num">1</span>); <span class="php-keyword1">if</span>(<span class="php-quote">'/'</span> != <span class="php-var">$depr</span>) { <span class="php-var">$url</span> = <span class="php-keyword2">str_replace</span>(<span class="php-quote">'/'</span>,<span class="php-var">$depr</span>,<span class="php-var">$url</span>); } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-quote">'/'</span> != <span class="php-var">$depr</span>) { <span class="php-var">$url</span> = <span class="php-keyword2">str_replace</span>(<span class="php-quote">'/'</span>,<span class="php-var">$depr</span>,<span class="php-var">$url</span>); } <span class="php-var">$url</span> = <span class="php-keyword2">trim</span>(<span class="php-var">$url</span>,<span class="php-var">$depr</span>); <span class="php-var">$path</span> = <span class="php-keyword2">explode</span>(<span class="php-var">$depr</span>,<span class="php-var">$url</span>); <span class="php-var">$var</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$varModule</span> = C(<span class="php-quote">'VAR_MODULE'</span>); <span class="php-var">$varController</span> = C(<span class="php-quote">'VAR_CONTROLLER'</span>); <span class="php-var">$varAction</span> = C(<span class="php-quote">'VAR_ACTION'</span>); <span class="php-var">$var</span>[<span class="php-var">$varAction</span>] = !<span class="php-keyword1">empty</span>(<span class="php-var">$path</span>)?<span class="php-keyword2">array_pop</span>(<span class="php-var">$path</span>):ACTION_NAME; <span class="php-var">$var</span>[<span class="php-var">$varController</span>] = !<span class="php-keyword1">empty</span>(<span class="php-var">$path</span>)?<span class="php-keyword2">array_pop</span>(<span class="php-var">$path</span>):CONTROLLER_NAME; <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_ACTION_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$var</span>[<span class="php-var">$varController</span>])])) { <span class="php-var">$maps</span> = <span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$var</span>[<span class="php-var">$varController</span>])]; <span class="php-keyword1">if</span>(<span class="php-var">$action</span> = <span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$var</span>[<span class="php-var">$varAction</span>]),<span class="php-var">$maps</span>)){ <span class="php-var">$var</span>[<span class="php-var">$varAction</span>] = <span class="php-var">$action</span>; } } } <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_CONTROLLER_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$controller</span> = <span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$var</span>[<span class="php-var">$varController</span>]),<span class="php-var">$maps</span>)){ <span class="php-var">$var</span>[<span class="php-var">$varController</span>] = <span class="php-var">$controller</span>; } } <span class="php-keyword1">if</span>(<span class="php-var">$urlCase</span>) { <span class="php-var">$var</span>[<span class="php-var">$varController</span>] = parse_name(<span class="php-var">$var</span>[<span class="php-var">$varController</span>]); } <span class="php-var">$module</span> = <span class="php-quote">''</span>; <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$path</span>)) { <span class="php-var">$var</span>[<span class="php-var">$varModule</span>] = <span class="php-keyword2">implode</span>(<span class="php-var">$depr</span>,<span class="php-var">$path</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(C(<span class="php-quote">'MULTI_MODULE'</span>)) { <span class="php-keyword1">if</span>(MODULE_NAME != C(<span class="php-quote">'DEFAULT_MODULE'</span>) || !C(<span class="php-quote">'MODULE_ALLOW_LIST'</span>)){ <span class="php-var">$var</span>[<span class="php-var">$varModule</span>]= MODULE_NAME; } } } <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_MODULE_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$_module</span> = <span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$var</span>[<span class="php-var">$varModule</span>]),<span class="php-var">$maps</span>)){ <span class="php-var">$var</span>[<span class="php-var">$varModule</span>] = <span class="php-var">$_module</span>; } } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$var</span>[<span class="php-var">$varModule</span>])){ <span class="php-var">$module</span> = <span class="php-var">$var</span>[<span class="php-var">$varModule</span>]; <span class="php-keyword1">unset</span>(<span class="php-var">$var</span>[<span class="php-var">$varModule</span>]); } } } <span class="php-keyword1">if</span>(C(<span class="php-quote">'URL_MODEL'</span>) == <span class="php-num">0</span>) { <span class="php-var">$url</span> = __APP__.<span class="php-quote">'?'</span>.C(<span class="php-quote">'VAR_MODULE'</span>).<span class="php-quote">&quot;=</span><span class="php-var">{$module}</span><span class="php-quote">&amp;&quot;</span>.<span class="php-keyword2">http_build_query</span>(<span class="php-keyword2">array_reverse</span>(<span class="php-var">$var</span>)); <span class="php-keyword1">if</span>(<span class="php-var">$urlCase</span>){ <span class="php-var">$url</span> = <span class="php-keyword2">strtolower</span>(<span class="php-var">$url</span>); } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$vars</span>)) { <span class="php-var">$vars</span> = <span class="php-keyword2">http_build_query</span>(<span class="php-var">$vars</span>); <span class="php-var">$url</span> .= <span class="php-quote">'&amp;'</span>.<span class="php-var">$vars</span>; } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$route</span>)) { <span class="php-var">$url</span> = __APP__.<span class="php-quote">'/'</span>.<span class="php-keyword2">rtrim</span>(<span class="php-var">$url</span>,<span class="php-var">$depr</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$module</span> = (<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_MODULE'</span>) &amp;&amp; BIND_MODULE==<span class="php-var">$module</span> )? <span class="php-quote">''</span> : <span class="php-var">$module</span>; <span class="php-var">$url</span> = __APP__.<span class="php-quote">'/'</span>.(<span class="php-var">$module</span>?<span class="php-var">$module</span>.MODULE_PATHINFO_DEPR:<span class="php-quote">''</span>).<span class="php-keyword2">implode</span>(<span class="php-var">$depr</span>,<span class="php-keyword2">array_reverse</span>(<span class="php-var">$var</span>)); } <span class="php-keyword1">if</span>(<span class="php-var">$urlCase</span>){ <span class="php-var">$url</span> = <span class="php-keyword2">strtolower</span>(<span class="php-var">$url</span>); } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$vars</span>)) { <span class="php-keyword1">foreach</span> (<span class="php-var">$vars</span> <span class="php-keyword1">as</span> <span class="php-var">$var</span> =&gt; <span class="php-var">$val</span>){ <span class="php-keyword1">if</span>(<span class="php-quote">''</span> !== <span class="php-keyword2">trim</span>(<span class="php-var">$val</span>)) <span class="php-var">$url</span> .= <span class="php-var">$depr</span> . <span class="php-var">$var</span> . <span class="php-var">$depr</span> . <span class="php-keyword2">urlencode</span>(<span class="php-var">$val</span>); } } <span class="php-keyword1">if</span>(<span class="php-var">$suffix</span>) { <span class="php-var">$suffix</span> = <span class="php-var">$suffix</span>===<span class="php-keyword1">true</span>?C(<span class="php-quote">'URL_HTML_SUFFIX'</span>):<span class="php-var">$suffix</span>; <span class="php-keyword1">if</span>(<span class="php-var">$pos</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$suffix</span>, <span class="php-quote">'|'</span>)){ <span class="php-var">$suffix</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$suffix</span>, <span class="php-num">0</span>, <span class="php-var">$pos</span>); } <span class="php-keyword1">if</span>(<span class="php-var">$suffix</span> &amp;&amp; <span class="php-quote">'/'</span> != <span class="php-keyword2">substr</span>(<span class="php-var">$url</span>,-<span class="php-num">1</span>)){ <span class="php-var">$url</span> .= <span class="php-quote">'.'</span>.<span class="php-keyword2">ltrim</span>(<span class="php-var">$suffix</span>,<span class="php-quote">'.'</span>); } } } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$anchor</span>)){ <span class="php-var">$url</span> .= <span class="php-quote">'#'</span>.<span class="php-var">$anchor</span>; } <span class="php-keyword1">if</span>(<span class="php-var">$domain</span>) { <span class="php-var">$url</span> = (is_ssl()?<span class="php-quote">'https://'</span>:<span class="php-quote">'http://'</span>).<span class="php-var">$domain</span>.<span class="php-var">$url</span>; } <span class="php-keyword1">return</span> <span class="php-var">$url</span>; } <span class="php-keyword1">function</span> W(<span class="php-var">$name</span>, <span class="php-var">$data</span>=<span class="php-keyword1">array</span>()) { <span class="php-keyword1">return</span> R(<span class="php-var">$name</span>,<span class="php-var">$data</span>,<span class="php-quote">'Widget'</span>); } <span class="php-keyword1">function</span> is_ssl() { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTPS'</span>]) &amp;&amp; (<span class="php-quote">'1'</span> == <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTPS'</span>] || <span class="php-quote">'on'</span> == <span class="php-keyword2">strtolower</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTPS'</span>]))){ <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'SERVER_PORT'</span>]) &amp;&amp; (<span class="php-quote">'443'</span> == <span class="php-var">$_SERVER</span>[<span class="php-quote">'SERVER_PORT'</span>] )) { <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-keyword1">function</span> redirect(<span class="php-var">$url</span>, <span class="php-var">$time</span>=<span class="php-num">0</span>, <span class="php-var">$msg</span>=<span class="php-quote">''</span>) { <span class="php-var">$url</span> = <span class="php-keyword2">str_replace</span>(<span class="php-keyword1">array</span>(<span class="php-quote">&quot;\n&quot;</span>, <span class="php-quote">&quot;\r&quot;</span>), <span class="php-quote">''</span>, <span class="php-var">$url</span>); <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$msg</span>)) <span class="php-var">$msg</span> = <span class="php-quote">&quot;系统将在</span><span class="php-var">{$time}</span><span class="php-quote">秒之后自动跳转到</span><span class="php-var">{$url}</span><span class="php-quote">！&quot;</span>; <span class="php-keyword1">if</span> (!<span class="php-keyword2">headers_sent</span>()) { <span class="php-keyword1">if</span> (<span class="php-num">0</span> === <span class="php-var">$time</span>) { <span class="php-keyword2">header</span>(<span class="php-quote">'Location: '</span> . <span class="php-var">$url</span>); } <span class="php-keyword1">else</span> { <span class="php-keyword2">header</span>(<span class="php-quote">&quot;refresh:</span><span class="php-var">{$time}</span><span class="php-quote">;url=</span><span class="php-var">{$url}</span><span class="php-quote">&quot;</span>); <span class="php-keyword1">echo</span>(<span class="php-var">$msg</span>); } <span class="php-keyword1">exit</span>(); } <span class="php-keyword1">else</span> { <span class="php-var">$str</span> = <span class="php-quote">&quot;&lt;meta http-equiv='Refresh' content='</span><span class="php-var">{$time}</span><span class="php-quote">;URL=</span><span class="php-var">{$url}</span><span class="php-quote">'&gt;&quot;</span>; <span class="php-keyword1">if</span> (<span class="php-var">$time</span> != <span class="php-num">0</span>) <span class="php-var">$str</span> .= <span class="php-var">$msg</span>; <span class="php-keyword1">exit</span>(<span class="php-var">$str</span>); } } <span class="php-keyword1">function</span> S(<span class="php-var">$name</span>,<span class="php-var">$value</span>=<span class="php-quote">''</span>,<span class="php-var">$options</span>=<span class="php-keyword1">null</span>) { <span class="php-keyword1">static</span> <span class="php-var">$cache</span> = <span class="php-quote">''</span>; <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$options</span>)){ <span class="php-var">$type</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$options</span>[<span class="php-quote">'type'</span>])?<span class="php-var">$options</span>[<span class="php-quote">'type'</span>]:<span class="php-quote">''</span>; <span class="php-var">$cache</span> = Think\Cache::getInstance(<span class="php-var">$type</span>,<span class="php-var">$options</span>); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)) { <span class="php-var">$type</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'type'</span>])?<span class="php-var">$name</span>[<span class="php-quote">'type'</span>]:<span class="php-quote">''</span>; <span class="php-var">$cache</span> = Think\Cache::getInstance(<span class="php-var">$type</span>,<span class="php-var">$name</span>); <span class="php-keyword1">return</span> <span class="php-var">$cache</span>; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$cache</span>)) { <span class="php-var">$cache</span> = Think\Cache::getInstance(); } <span class="php-keyword1">if</span>(<span class="php-quote">''</span>=== <span class="php-var">$value</span>){ <span class="php-keyword1">return</span> <span class="php-var">$cache</span>-&gt;get(<span class="php-var">$name</span>); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)) { <span class="php-keyword1">return</span> <span class="php-var">$cache</span>-&gt;rm(<span class="php-var">$name</span>); }<span class="php-keyword1">else</span> { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$options</span>)) { <span class="php-var">$expire</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$options</span>[<span class="php-quote">'expire'</span>])?<span class="php-var">$options</span>[<span class="php-quote">'expire'</span>]:<span class="php-keyword1">NULL</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$expire</span> = <span class="php-keyword2">is_numeric</span>(<span class="php-var">$options</span>)?<span class="php-var">$options</span>:<span class="php-keyword1">NULL</span>; } <span class="php-keyword1">return</span> <span class="php-var">$cache</span>-&gt;set(<span class="php-var">$name</span>, <span class="php-var">$value</span>, <span class="php-var">$expire</span>); } } <span class="php-keyword1">function</span> F(<span class="php-var">$name</span>, <span class="php-var">$value</span>=<span class="php-quote">''</span>, <span class="php-var">$path</span>=DATA_PATH) { <span class="php-keyword1">static</span> <span class="php-var">$_cache</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$filename</span> = <span class="php-var">$path</span> . <span class="php-var">$name</span> . <span class="php-quote">'.php'</span>; <span class="php-keyword1">if</span> (<span class="php-quote">''</span> !== <span class="php-var">$value</span>) { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'*'</span>)){ <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">unset</span>(<span class="php-var">$_cache</span>[<span class="php-var">$name</span>]); <span class="php-keyword1">return</span> Think\Storage::<span class="php-keyword2">unlink</span>(<span class="php-var">$filename</span>,<span class="php-quote">'F'</span>); } } <span class="php-keyword1">else</span> { Think\Storage::put(<span class="php-var">$filename</span>,<span class="php-keyword2">serialize</span>(<span class="php-var">$value</span>),<span class="php-quote">'F'</span>); <span class="php-var">$_cache</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } } <span class="php-keyword1">if</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_cache</span>[<span class="php-var">$name</span>])) <span class="php-keyword1">return</span> <span class="php-var">$_cache</span>[<span class="php-var">$name</span>]; <span class="php-keyword1">if</span> (Think\Storage::has(<span class="php-var">$filename</span>,<span class="php-quote">'F'</span>)){ <span class="php-var">$value</span> = <span class="php-keyword2">unserialize</span>(Think\Storage::read(<span class="php-var">$filename</span>,<span class="php-quote">'F'</span>)); <span class="php-var">$_cache</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; } <span class="php-keyword1">else</span> { <span class="php-var">$value</span> = <span class="php-keyword1">false</span>; } <span class="php-keyword1">return</span> <span class="php-var">$value</span>; } <span class="php-keyword1">function</span> to_guid_string(<span class="php-var">$mix</span>) { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_object</span>(<span class="php-var">$mix</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword2">spl_object_hash</span>(<span class="php-var">$mix</span>); } <span class="php-keyword1">elseif</span> (<span class="php-keyword2">is_resource</span>(<span class="php-var">$mix</span>)) { <span class="php-var">$mix</span> = <span class="php-keyword2">get_resource_type</span>(<span class="php-var">$mix</span>) . <span class="php-keyword2">strval</span>(<span class="php-var">$mix</span>); } <span class="php-keyword1">else</span> { <span class="php-var">$mix</span> = <span class="php-keyword2">serialize</span>(<span class="php-var">$mix</span>); } <span class="php-keyword1">return</span> <span class="php-keyword2">md5</span>(<span class="php-var">$mix</span>); } <span class="php-keyword1">function</span> xml_encode(<span class="php-var">$data</span>, <span class="php-var">$root</span>=<span class="php-quote">'think'</span>, <span class="php-var">$item</span>=<span class="php-quote">'item'</span>, <span class="php-var">$attr</span>=<span class="php-quote">''</span>, <span class="php-var">$id</span>=<span class="php-quote">'id'</span>, <span class="php-var">$encoding</span>=<span class="php-quote">'utf-8'</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$attr</span>)){ <span class="php-var">$_attr</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">foreach</span> (<span class="php-var">$attr</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$value</span>) { <span class="php-var">$_attr</span>[] = <span class="php-quote">&quot;</span><span class="php-var">{$key}</span><span class="php-quote">=\&quot;</span><span class="php-var">{$value}</span><span class="php-quote">\&quot;&quot;</span>; } <span class="php-var">$attr</span> = <span class="php-keyword2">implode</span>(<span class="php-quote">' '</span>, <span class="php-var">$_attr</span>); } <span class="php-var">$attr</span> = <span class="php-keyword2">trim</span>(<span class="php-var">$attr</span>); <span class="php-var">$attr</span> = <span class="php-keyword1">empty</span>(<span class="php-var">$attr</span>) ? <span class="php-quote">''</span> : <span class="php-quote">&quot; </span><span class="php-var">{$attr}</span><span class="php-quote">&quot;</span>; <span class="php-var">$xml</span> = <span class="php-quote">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;</span><span class="php-var">{$encoding}</span><span class="php-quote">\&quot;?&gt;&quot;</span>; <span class="php-var">$xml</span> .= <span class="php-quote">&quot;&lt;</span><span class="php-var">{$root}{$attr}</span><span class="php-quote">&gt;&quot;</span>; <span class="php-var">$xml</span> .= data_to_xml(<span class="php-var">$data</span>, <span class="php-var">$item</span>, <span class="php-var">$id</span>); <span class="php-var">$xml</span> .= <span class="php-quote">&quot;&lt;/</span><span class="php-var">{$root}</span><span class="php-quote">&gt;&quot;</span>; <span class="php-keyword1">return</span> <span class="php-var">$xml</span>; } <span class="php-keyword1">function</span> data_to_xml(<span class="php-var">$data</span>, <span class="php-var">$item</span>=<span class="php-quote">'item'</span>, <span class="php-var">$id</span>=<span class="php-quote">'id'</span>) { <span class="php-var">$xml</span> = <span class="php-var">$attr</span> = <span class="php-quote">''</span>; <span class="php-keyword1">foreach</span> (<span class="php-var">$data</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$val</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_numeric</span>(<span class="php-var">$key</span>)){ <span class="php-var">$id</span> &amp;&amp; <span class="php-var">$attr</span> = <span class="php-quote">&quot; </span><span class="php-var">{$id}</span><span class="php-quote">=\&quot;</span><span class="php-var">{$key}</span><span class="php-quote">\&quot;&quot;</span>; <span class="php-var">$key</span> = <span class="php-var">$item</span>; } <span class="php-var">$xml</span> .= <span class="php-quote">&quot;&lt;</span><span class="php-var">{$key}{$attr}</span><span class="php-quote">&gt;&quot;</span>; <span class="php-var">$xml</span> .= (<span class="php-keyword2">is_array</span>(<span class="php-var">$val</span>) || <span class="php-keyword2">is_object</span>(<span class="php-var">$val</span>)) ? data_to_xml(<span class="php-var">$val</span>, <span class="php-var">$item</span>, <span class="php-var">$id</span>) : <span class="php-var">$val</span>; <span class="php-var">$xml</span> .= <span class="php-quote">&quot;&lt;/</span><span class="php-var">{$key}</span><span class="php-quote">&gt;&quot;</span>; } <span class="php-keyword1">return</span> <span class="php-var">$xml</span>; } <span class="php-keyword1">function</span> session(<span class="php-var">$name</span>=<span class="php-quote">''</span>,<span class="php-var">$value</span>=<span class="php-quote">''</span>) { <span class="php-var">$prefix</span> = C(<span class="php-quote">'SESSION_PREFIX'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'prefix'</span>])) C(<span class="php-quote">'SESSION_PREFIX'</span>,<span class="php-var">$name</span>[<span class="php-quote">'prefix'</span>]); <span class="php-keyword1">if</span>(C(<span class="php-quote">'VAR_SESSION_ID'</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$_REQUEST</span>[C(<span class="php-quote">'VAR_SESSION_ID'</span>)])){ <span class="php-keyword2">session_id</span>(<span class="php-var">$_REQUEST</span>[C(<span class="php-quote">'VAR_SESSION_ID'</span>)]); }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'id'</span>])) { <span class="php-keyword2">session_id</span>(<span class="php-var">$name</span>[<span class="php-quote">'id'</span>]); } <span class="php-keyword1">if</span>(<span class="php-quote">'common'</span> == APP_MODE){ <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.auto_start'</span>, <span class="php-num">0</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'name'</span>])) <span class="php-keyword2">session_name</span>(<span class="php-var">$name</span>[<span class="php-quote">'name'</span>]); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'path'</span>])) <span class="php-keyword2">session_save_path</span>(<span class="php-var">$name</span>[<span class="php-quote">'path'</span>]); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'domain'</span>])) <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.cookie_domain'</span>, <span class="php-var">$name</span>[<span class="php-quote">'domain'</span>]); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'expire'</span>])) { <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.gc_maxlifetime'</span>, <span class="php-var">$name</span>[<span class="php-quote">'expire'</span>]); <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.cookie_lifetime'</span>, <span class="php-var">$name</span>[<span class="php-quote">'expire'</span>]); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'use_trans_sid'</span>])) <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.use_trans_sid'</span>, <span class="php-var">$name</span>[<span class="php-quote">'use_trans_sid'</span>]?<span class="php-num">1</span>:<span class="php-num">0</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'use_cookies'</span>])) <span class="php-keyword2">ini_set</span>(<span class="php-quote">'session.use_cookies'</span>, <span class="php-var">$name</span>[<span class="php-quote">'use_cookies'</span>]?<span class="php-num">1</span>:<span class="php-num">0</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'cache_limiter'</span>])) <span class="php-keyword2">session_cache_limiter</span>(<span class="php-var">$name</span>[<span class="php-quote">'cache_limiter'</span>]); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'cache_expire'</span>])) <span class="php-keyword2">session_cache_expire</span>(<span class="php-var">$name</span>[<span class="php-quote">'cache_expire'</span>]); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$name</span>[<span class="php-quote">'type'</span>])) C(<span class="php-quote">'SESSION_TYPE'</span>,<span class="php-var">$name</span>[<span class="php-quote">'type'</span>]); <span class="php-keyword1">if</span>(C(<span class="php-quote">'SESSION_TYPE'</span>)) { <span class="php-var">$type</span> = C(<span class="php-quote">'SESSION_TYPE'</span>); <span class="php-var">$class</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$type</span>,<span class="php-quote">'\\'</span>)? <span class="php-var">$type</span> : <span class="php-quote">'Think\\Session\\Driver\\'</span>. <span class="php-keyword2">ucwords</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$type</span>)); <span class="php-var">$hander</span> = <span class="php-keyword1">new</span> <span class="php-var">$class</span>(); <span class="php-keyword2">session_set_save_handler</span>( <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;open&quot;</span>), <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;close&quot;</span>), <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;read&quot;</span>), <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;write&quot;</span>), <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;destroy&quot;</span>), <span class="php-keyword1">array</span>(&amp;<span class="php-var">$hander</span>,<span class="php-quote">&quot;gc&quot;</span>)); } <span class="php-keyword1">if</span>(C(<span class="php-quote">'SESSION_AUTO_START'</span>)) <span class="php-keyword2">session_start</span>(); }<span class="php-keyword1">elseif</span>(<span class="php-quote">''</span> === <span class="php-var">$value</span>){ <span class="php-keyword1">if</span>(<span class="php-quote">''</span>===<span class="php-var">$name</span>){ <span class="php-keyword1">return</span> <span class="php-var">$prefix</span> ? <span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>] : <span class="php-var">$_SESSION</span>; }<span class="php-keyword1">elseif</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'['</span>)) { <span class="php-keyword1">if</span>(<span class="php-quote">'[pause]'</span>==<span class="php-var">$name</span>){ <span class="php-keyword2">session_write_close</span>(); }<span class="php-keyword1">elseif</span>(<span class="php-quote">'[start]'</span>==<span class="php-var">$name</span>){ <span class="php-keyword2">session_start</span>(); }<span class="php-keyword1">elseif</span>(<span class="php-quote">'[destroy]'</span>==<span class="php-var">$name</span>){ <span class="php-var">$_SESSION</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword2">session_unset</span>(); <span class="php-keyword2">session_destroy</span>(); }<span class="php-keyword1">elseif</span>(<span class="php-quote">'[regenerate]'</span>==<span class="php-var">$name</span>){ <span class="php-keyword2">session_regenerate_id</span>(); } }<span class="php-keyword1">elseif</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'?'</span>)){ <span class="php-var">$name</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$name</span>,<span class="php-num">1</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name1</span>,<span class="php-var">$name2</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">return</span> <span class="php-var">$prefix</span>?<span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]):<span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-var">$prefix</span>?<span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name</span>]):<span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name</span>]); } }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_null</span>(<span class="php-var">$name</span>)){ <span class="php-keyword1">if</span>(<span class="php-var">$prefix</span>) { <span class="php-keyword1">unset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>]); }<span class="php-keyword1">else</span>{ <span class="php-var">$_SESSION</span> = <span class="php-keyword1">array</span>(); } }<span class="php-keyword1">elseif</span>(<span class="php-var">$prefix</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name1</span>,<span class="php-var">$name2</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name1</span>][<span class="php-var">$name2</span>])?<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]:<span class="php-keyword1">null</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name</span>])?<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name</span>]:<span class="php-keyword1">null</span>; } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name1</span>,<span class="php-var">$name2</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name1</span>][<span class="php-var">$name2</span>])?<span class="php-var">$_SESSION</span>[<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]:<span class="php-keyword1">null</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name</span>])?<span class="php-var">$_SESSION</span>[<span class="php-var">$name</span>]:<span class="php-keyword1">null</span>; } } }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)){ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name1</span>,<span class="php-var">$name2</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">if</span>(<span class="php-var">$prefix</span>){ <span class="php-keyword1">unset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">unset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name1</span>][<span class="php-var">$name2</span>]); } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-var">$prefix</span>){ <span class="php-keyword1">unset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name</span>]); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">unset</span>(<span class="php-var">$_SESSION</span>[<span class="php-var">$name</span>]); } } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$name</span>,<span class="php-quote">'.'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$name1</span>,<span class="php-var">$name2</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>,<span class="php-var">$name</span>); <span class="php-keyword1">if</span>(<span class="php-var">$prefix</span>){ <span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name1</span>][<span class="php-var">$name2</span>] = <span class="php-var">$value</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$_SESSION</span>[<span class="php-var">$name1</span>][<span class="php-var">$name2</span>] = <span class="php-var">$value</span>; } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-var">$prefix</span>){ <span class="php-var">$_SESSION</span>[<span class="php-var">$prefix</span>][<span class="php-var">$name</span>] = <span class="php-var">$value</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$_SESSION</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; } } } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> cookie(<span class="php-var">$name</span>=<span class="php-quote">''</span>, <span class="php-var">$value</span>=<span class="php-quote">''</span>, <span class="php-var">$option</span>=<span class="php-keyword1">null</span>) { <span class="php-var">$config</span> = <span class="php-keyword1">array</span>( <span class="php-quote">'prefix'</span> =&gt; C(<span class="php-quote">'COOKIE_PREFIX'</span>), <span class="php-quote">'expire'</span> =&gt; C(<span class="php-quote">'COOKIE_EXPIRE'</span>), <span class="php-quote">'path'</span> =&gt; C(<span class="php-quote">'COOKIE_PATH'</span>), <span class="php-quote">'domain'</span> =&gt; C(<span class="php-quote">'COOKIE_DOMAIN'</span>), <span class="php-quote">'secure'</span> =&gt; C(<span class="php-quote">'COOKIE_SECURE'</span>), <span class="php-quote">'httponly'</span> =&gt; C(<span class="php-quote">'COOKIE_HTTPONLY'</span>), ); <span class="php-keyword1">if</span> (!<span class="php-keyword2">is_null</span>(<span class="php-var">$option</span>)) { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_numeric</span>(<span class="php-var">$option</span>)) <span class="php-var">$option</span> = <span class="php-keyword1">array</span>(<span class="php-quote">'expire'</span> =&gt; <span class="php-var">$option</span>); <span class="php-keyword1">elseif</span> (<span class="php-keyword2">is_string</span>(<span class="php-var">$option</span>)) <span class="php-keyword2">parse_str</span>(<span class="php-var">$option</span>, <span class="php-var">$option</span>); <span class="php-var">$config</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$config</span>, <span class="php-keyword2">array_change_key_case</span>(<span class="php-var">$option</span>)); } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$config</span>[<span class="php-quote">'httponly'</span>])){ <span class="php-keyword2">ini_set</span>(<span class="php-quote">&quot;session.cookie_httponly&quot;</span>, <span class="php-num">1</span>); } <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$name</span>)) { <span class="php-keyword1">if</span> (<span class="php-keyword1">empty</span>(<span class="php-var">$_COOKIE</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; <span class="php-var">$prefix</span> = <span class="php-keyword1">empty</span>(<span class="php-var">$value</span>) ? <span class="php-var">$config</span>[<span class="php-quote">'prefix'</span>] : <span class="php-var">$value</span>; <span class="php-keyword1">if</span> (!<span class="php-keyword1">empty</span>(<span class="php-var">$prefix</span>)) { <span class="php-keyword1">foreach</span> (<span class="php-var">$_COOKIE</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$val</span>) { <span class="php-keyword1">if</span> (<span class="php-num">0</span> === <span class="php-keyword2">stripos</span>(<span class="php-var">$key</span>, <span class="php-var">$prefix</span>)) { <span class="php-keyword2">setcookie</span>(<span class="php-var">$key</span>, <span class="php-quote">''</span>, <span class="php-keyword2">time</span>() - <span class="php-num">3600</span>, <span class="php-var">$config</span>[<span class="php-quote">'path'</span>], <span class="php-var">$config</span>[<span class="php-quote">'domain'</span>],<span class="php-var">$config</span>[<span class="php-quote">'secure'</span>],<span class="php-var">$config</span>[<span class="php-quote">'httponly'</span>]); <span class="php-keyword1">unset</span>(<span class="php-var">$_COOKIE</span>[<span class="php-var">$key</span>]); } } } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; }<span class="php-keyword1">elseif</span>(<span class="php-quote">''</span> === <span class="php-var">$name</span>){ <span class="php-keyword1">return</span> <span class="php-var">$_COOKIE</span>; } <span class="php-var">$name</span> = <span class="php-var">$config</span>[<span class="php-quote">'prefix'</span>] . <span class="php-keyword2">str_replace</span>(<span class="php-quote">'.'</span>, <span class="php-quote">'_'</span>, <span class="php-var">$name</span>); <span class="php-keyword1">if</span> (<span class="php-quote">''</span> === <span class="php-var">$value</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_COOKIE</span>[<span class="php-var">$name</span>])){ <span class="php-var">$value</span> = <span class="php-var">$_COOKIE</span>[<span class="php-var">$name</span>]; <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$value</span>,<span class="php-quote">'think:'</span>)){ <span class="php-var">$value</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$value</span>,<span class="php-num">6</span>); <span class="php-keyword1">return</span> <span class="php-keyword2">array_map</span>(<span class="php-quote">'urldecode'</span>,<span class="php-keyword2">json_decode</span>(MAGIC_QUOTES_GPC?<span class="php-keyword2">stripslashes</span>(<span class="php-var">$value</span>):<span class="php-var">$value</span>,<span class="php-keyword1">true</span>)); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-var">$value</span>; } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } } <span class="php-keyword1">else</span> { <span class="php-keyword1">if</span> (<span class="php-keyword2">is_null</span>(<span class="php-var">$value</span>)) { <span class="php-keyword2">setcookie</span>(<span class="php-var">$name</span>, <span class="php-quote">''</span>, <span class="php-keyword2">time</span>() - <span class="php-num">3600</span>, <span class="php-var">$config</span>[<span class="php-quote">'path'</span>], <span class="php-var">$config</span>[<span class="php-quote">'domain'</span>],<span class="php-var">$config</span>[<span class="php-quote">'secure'</span>],<span class="php-var">$config</span>[<span class="php-quote">'httponly'</span>]); <span class="php-keyword1">unset</span>(<span class="php-var">$_COOKIE</span>[<span class="php-var">$name</span>]); } <span class="php-keyword1">else</span> { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$value</span>)){ <span class="php-var">$value</span> = <span class="php-quote">'think:'</span>.<span class="php-keyword2">json_encode</span>(<span class="php-keyword2">array_map</span>(<span class="php-quote">'urlencode'</span>,<span class="php-var">$value</span>)); } <span class="php-var">$expire</span> = !<span class="php-keyword1">empty</span>(<span class="php-var">$config</span>[<span class="php-quote">'expire'</span>]) ? <span class="php-keyword2">time</span>() + <span class="php-keyword2">intval</span>(<span class="php-var">$config</span>[<span class="php-quote">'expire'</span>]) : <span class="php-num">0</span>; <span class="php-keyword2">setcookie</span>(<span class="php-var">$name</span>, <span class="php-var">$value</span>, <span class="php-var">$expire</span>, <span class="php-var">$config</span>[<span class="php-quote">'path'</span>], <span class="php-var">$config</span>[<span class="php-quote">'domain'</span>],<span class="php-var">$config</span>[<span class="php-quote">'secure'</span>],<span class="php-var">$config</span>[<span class="php-quote">'httponly'</span>]); <span class="php-var">$_COOKIE</span>[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; } } <span class="php-keyword1">return</span> <span class="php-keyword1">null</span>; } <span class="php-keyword1">function</span> load_ext_file(<span class="php-var">$path</span>) { <span class="php-keyword1">if</span>(<span class="php-var">$files</span> = C(<span class="php-quote">'LOAD_EXT_FILE'</span>)) { <span class="php-var">$files</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,<span class="php-var">$files</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$files</span> <span class="php-keyword1">as</span> <span class="php-var">$file</span>){ <span class="php-var">$file</span> = <span class="php-var">$path</span>.<span class="php-quote">'Common/'</span>.<span class="php-var">$file</span>.<span class="php-quote">'.php'</span>; <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(<span class="php-var">$file</span>)) <span class="php-keyword1">include</span> <span class="php-var">$file</span>; } } <span class="php-keyword1">if</span>(<span class="php-var">$configs</span> = C(<span class="php-quote">'LOAD_EXT_CONFIG'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_string</span>(<span class="php-var">$configs</span>)) <span class="php-var">$configs</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,<span class="php-var">$configs</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$configs</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span>=&gt;<span class="php-var">$config</span>){ <span class="php-var">$file</span> = <span class="php-keyword2">is_file</span>(<span class="php-var">$config</span>)? <span class="php-var">$config</span> : <span class="php-var">$path</span>.<span class="php-quote">'Conf/'</span>.<span class="php-var">$config</span>.CONF_EXT; <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(<span class="php-var">$file</span>)) { <span class="php-keyword2">is_numeric</span>(<span class="php-var">$key</span>)?C(load_config(<span class="php-var">$file</span>)):C(<span class="php-var">$key</span>,load_config(<span class="php-var">$file</span>)); } } } } <span class="php-keyword1">function</span> get_client_ip(<span class="php-var">$type</span> = <span class="php-num">0</span>,<span class="php-var">$adv</span>=<span class="php-keyword1">false</span>) { <span class="php-var">$type</span> = <span class="php-var">$type</span> ? <span class="php-num">1</span> : <span class="php-num">0</span>; <span class="php-keyword1">static</span> <span class="php-var">$ip</span> = <span class="php-keyword1">NULL</span>; <span class="php-keyword1">if</span> (<span class="php-var">$ip</span> !== <span class="php-keyword1">NULL</span>) <span class="php-keyword1">return</span> <span class="php-var">$ip</span>[<span class="php-var">$type</span>]; <span class="php-keyword1">if</span>(<span class="php-var">$adv</span>){ <span class="php-keyword1">if</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_X_FORWARDED_FOR'</span>])) { <span class="php-var">$arr</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_X_FORWARDED_FOR'</span>]); <span class="php-var">$pos</span> = <span class="php-keyword2">array_search</span>(<span class="php-quote">'unknown'</span>,<span class="php-var">$arr</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-var">$pos</span>) <span class="php-keyword1">unset</span>(<span class="php-var">$arr</span>[<span class="php-var">$pos</span>]); <span class="php-var">$ip</span> = <span class="php-keyword2">trim</span>(<span class="php-var">$arr</span>[<span class="php-num">0</span>]); }<span class="php-keyword1">elseif</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_CLIENT_IP'</span>])) { <span class="php-var">$ip</span> = <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_CLIENT_IP'</span>]; }<span class="php-keyword1">elseif</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'REMOTE_ADDR'</span>])) { <span class="php-var">$ip</span> = <span class="php-var">$_SERVER</span>[<span class="php-quote">'REMOTE_ADDR'</span>]; } }<span class="php-keyword1">elseif</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'REMOTE_ADDR'</span>])) { <span class="php-var">$ip</span> = <span class="php-var">$_SERVER</span>[<span class="php-quote">'REMOTE_ADDR'</span>]; } <span class="php-var">$long</span> = <span class="php-keyword2">sprintf</span>(<span class="php-quote">&quot;%u&quot;</span>,<span class="php-keyword2">ip2long</span>(<span class="php-var">$ip</span>)); <span class="php-var">$ip</span> = <span class="php-var">$long</span> ? <span class="php-keyword1">array</span>(<span class="php-var">$ip</span>, <span class="php-var">$long</span>) : <span class="php-keyword1">array</span>(<span class="php-quote">'0.0.0.0'</span>, <span class="php-num">0</span>); <span class="php-keyword1">return</span> <span class="php-var">$ip</span>[<span class="php-var">$type</span>]; } <span class="php-keyword1">function</span> send_http_status(<span class="php-var">$code</span>) { <span class="php-keyword1">static</span> <span class="php-var">$_status</span> = <span class="php-keyword1">array</span>( <span class="php-num">100</span> =&gt; <span class="php-quote">'Continue'</span>, <span class="php-num">101</span> =&gt; <span class="php-quote">'Switching Protocols'</span>, <span class="php-num">200</span> =&gt; <span class="php-quote">'OK'</span>, <span class="php-num">201</span> =&gt; <span class="php-quote">'Created'</span>, <span class="php-num">202</span> =&gt; <span class="php-quote">'Accepted'</span>, <span class="php-num">203</span> =&gt; <span class="php-quote">'Non-Authoritative Information'</span>, <span class="php-num">204</span> =&gt; <span class="php-quote">'No Content'</span>, <span class="php-num">205</span> =&gt; <span class="php-quote">'Reset Content'</span>, <span class="php-num">206</span> =&gt; <span class="php-quote">'Partial Content'</span>, <span class="php-num">300</span> =&gt; <span class="php-quote">'Multiple Choices'</span>, <span class="php-num">301</span> =&gt; <span class="php-quote">'Moved Permanently'</span>, <span class="php-num">302</span> =&gt; <span class="php-quote">'Moved Temporarily '</span>, <span class="php-num">303</span> =&gt; <span class="php-quote">'See Other'</span>, <span class="php-num">304</span> =&gt; <span class="php-quote">'Not Modified'</span>, <span class="php-num">305</span> =&gt; <span class="php-quote">'Use Proxy'</span>, <span class="php-num">307</span> =&gt; <span class="php-quote">'Temporary Redirect'</span>, <span class="php-num">400</span> =&gt; <span class="php-quote">'Bad Request'</span>, <span class="php-num">401</span> =&gt; <span class="php-quote">'Unauthorized'</span>, <span class="php-num">402</span> =&gt; <span class="php-quote">'Payment Required'</span>, <span class="php-num">403</span> =&gt; <span class="php-quote">'Forbidden'</span>, <span class="php-num">404</span> =&gt; <span class="php-quote">'Not Found'</span>, <span class="php-num">405</span> =&gt; <span class="php-quote">'Method Not Allowed'</span>, <span class="php-num">406</span> =&gt; <span class="php-quote">'Not Acceptable'</span>, <span class="php-num">407</span> =&gt; <span class="php-quote">'Proxy Authentication Required'</span>, <span class="php-num">408</span> =&gt; <span class="php-quote">'Request Timeout'</span>, <span class="php-num">409</span> =&gt; <span class="php-quote">'Conflict'</span>, <span class="php-num">410</span> =&gt; <span class="php-quote">'Gone'</span>, <span class="php-num">411</span> =&gt; <span class="php-quote">'Length Required'</span>, <span class="php-num">412</span> =&gt; <span class="php-quote">'Precondition Failed'</span>, <span class="php-num">413</span> =&gt; <span class="php-quote">'Request Entity Too Large'</span>, <span class="php-num">414</span> =&gt; <span class="php-quote">'Request-URI Too Long'</span>, <span class="php-num">415</span> =&gt; <span class="php-quote">'Unsupported Media Type'</span>, <span class="php-num">416</span> =&gt; <span class="php-quote">'Requested Range Not Satisfiable'</span>, <span class="php-num">417</span> =&gt; <span class="php-quote">'Expectation Failed'</span>, <span class="php-num">500</span> =&gt; <span class="php-quote">'Internal Server Error'</span>, <span class="php-num">501</span> =&gt; <span class="php-quote">'Not Implemented'</span>, <span class="php-num">502</span> =&gt; <span class="php-quote">'Bad Gateway'</span>, <span class="php-num">503</span> =&gt; <span class="php-quote">'Service Unavailable'</span>, <span class="php-num">504</span> =&gt; <span class="php-quote">'Gateway Timeout'</span>, <span class="php-num">505</span> =&gt; <span class="php-quote">'HTTP Version Not Supported'</span>, <span class="php-num">509</span> =&gt; <span class="php-quote">'Bandwidth Limit Exceeded'</span> ); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_status</span>[<span class="php-var">$code</span>])) { <span class="php-keyword2">header</span>(<span class="php-quote">'HTTP/1.1 '</span>.<span class="php-var">$code</span>.<span class="php-quote">' '</span>.<span class="php-var">$_status</span>[<span class="php-var">$code</span>]); <span class="php-keyword2">header</span>(<span class="php-quote">'Status:'</span>.<span class="php-var">$code</span>.<span class="php-quote">' '</span>.<span class="php-var">$_status</span>[<span class="php-var">$code</span>]); } } <span class="php-keyword1">function</span> think_filter(&amp;<span class="php-var">$value</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">preg_match</span>(<span class="php-quote">'/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOTIN|NOT IN|IN)$/i'</span>,<span class="php-var">$value</span>)){ <span class="php-var">$value</span> .= <span class="php-quote">' '</span>; } } <span class="php-keyword1">function</span> in_array_case(<span class="php-var">$value</span>,<span class="php-var">$array</span>){ <span class="php-keyword1">return</span> <span class="php-keyword2">in_array</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$value</span>),<span class="php-keyword2">array_map</span>(<span class="php-quote">'strtolower'</span>,<span class="php-var">$array</span>)); }}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">class</span> Hook { <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-var">$tags</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> add(<span class="php-var">$tag</span>,<span class="php-var">$name</span>) { <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>])){ self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] = <span class="php-keyword1">array</span>(); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)){ self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] = <span class="php-keyword2">array_merge</span>(self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>],<span class="php-var">$name</span>); }<span class="php-keyword1">else</span>{ self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>][] = <span class="php-var">$name</span>; } } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> import(<span class="php-var">$data</span>,<span class="php-var">$recursive</span>=<span class="php-keyword1">true</span>) { <span class="php-keyword1">if</span>(!<span class="php-var">$recursive</span>){ self::<span class="php-var">$tags</span> = <span class="php-keyword2">array_merge</span>(self::<span class="php-var">$tags</span>,<span class="php-var">$data</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword1">foreach</span> (<span class="php-var">$data</span> <span class="php-keyword1">as</span> <span class="php-var">$tag</span>=&gt;<span class="php-var">$val</span>){ <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>])) self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$val</span>[<span class="php-quote">'_overlay'</span>])){ <span class="php-keyword1">unset</span>(<span class="php-var">$val</span>[<span class="php-quote">'_overlay'</span>]); self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] = <span class="php-var">$val</span>; }<span class="php-keyword1">else</span>{ self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] = <span class="php-keyword2">array_merge</span>(self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>],<span class="php-var">$val</span>); } } } } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> get(<span class="php-var">$tag</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$tag</span>)){ <span class="php-keyword1">return</span> self::<span class="php-var">$tags</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>]; } } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> listen(<span class="php-var">$tag</span>, &amp;<span class="php-var">$params</span>=<span class="php-keyword1">NULL</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>])) { <span class="php-keyword1">if</span>(APP_DEBUG) { G(<span class="php-var">$tag</span>.<span class="php-quote">'Start'</span>); trace(<span class="php-quote">'[ '</span>.<span class="php-var">$tag</span>.<span class="php-quote">' ] --START--'</span>,<span class="php-quote">''</span>,<span class="php-quote">'INFO'</span>); } <span class="php-keyword1">foreach</span> (self::<span class="php-var">$tags</span>[<span class="php-var">$tag</span>] <span class="php-keyword1">as</span> <span class="php-var">$name</span>) { APP_DEBUG &amp;&amp; G(<span class="php-var">$name</span>.<span class="php-quote">'_start'</span>); <span class="php-var">$result</span> = self::<span class="php-keyword2">exec</span>(<span class="php-var">$name</span>, <span class="php-var">$tag</span>,<span class="php-var">$params</span>); <span class="php-keyword1">if</span>(APP_DEBUG){ G(<span class="php-var">$name</span>.<span class="php-quote">'_end'</span>); trace(<span class="php-quote">'Run '</span>.<span class="php-var">$name</span>.<span class="php-quote">' [ RunTime:'</span>.G(<span class="php-var">$name</span>.<span class="php-quote">'_start'</span>,<span class="php-var">$name</span>.<span class="php-quote">'_end'</span>,<span class="php-num">6</span>).<span class="php-quote">'s ]'</span>,<span class="php-quote">''</span>,<span class="php-quote">'INFO'</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> === <span class="php-var">$result</span>) { <span class="php-keyword1">return</span> ; } } <span class="php-keyword1">if</span>(APP_DEBUG) { trace(<span class="php-quote">'[ '</span>.<span class="php-var">$tag</span>.<span class="php-quote">' ] --END-- [ RunTime:'</span>.G(<span class="php-var">$tag</span>.<span class="php-quote">'Start'</span>,<span class="php-var">$tag</span>.<span class="php-quote">'End'</span>,<span class="php-num">6</span>).<span class="php-quote">'s ]'</span>,<span class="php-quote">''</span>,<span class="php-quote">'INFO'</span>); } } <span class="php-keyword1">return</span>; } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> <span class="php-keyword2">exec</span>(<span class="php-var">$name</span>, <span class="php-var">$tag</span>,&amp;<span class="php-var">$params</span>=<span class="php-keyword1">NULL</span>) { <span class="php-keyword1">if</span>(<span class="php-quote">'Behavior'</span> == <span class="php-keyword2">substr</span>(<span class="php-var">$name</span>,-<span class="php-num">8</span>) ){ <span class="php-var">$tag</span> = <span class="php-quote">'run'</span>; } <span class="php-var">$addon</span> = <span class="php-keyword1">new</span> <span class="php-var">$name</span>(); <span class="php-keyword1">return</span> <span class="php-var">$addon</span>-&gt;<span class="php-var">$tag</span>(<span class="php-var">$params</span>); } }}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">class</span> App { <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> init() { load_ext_file(COMMON_PATH); C(<span class="php-quote">'LOG_PATH'</span>, <span class="php-keyword2">realpath</span>(LOG_PATH).<span class="php-quote">'/Common/'</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'NOW_TIME'</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'REQUEST_TIME'</span>]); <span class="php-keyword2">define</span>(<span class="php-quote">'REQUEST_METHOD'</span>,<span class="php-var">$_SERVER</span>[<span class="php-quote">'REQUEST_METHOD'</span>]); <span class="php-keyword2">define</span>(<span class="php-quote">'IS_GET'</span>, REQUEST_METHOD ==<span class="php-quote">'GET'</span> ? <span class="php-keyword1">true</span> : <span class="php-keyword1">false</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'IS_POST'</span>, REQUEST_METHOD ==<span class="php-quote">'POST'</span> ? <span class="php-keyword1">true</span> : <span class="php-keyword1">false</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'IS_PUT'</span>, REQUEST_METHOD ==<span class="php-quote">'PUT'</span> ? <span class="php-keyword1">true</span> : <span class="php-keyword1">false</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'IS_DELETE'</span>, REQUEST_METHOD ==<span class="php-quote">'DELETE'</span> ? <span class="php-keyword1">true</span> : <span class="php-keyword1">false</span>); Dispatcher::dispatch(); <span class="php-keyword1">if</span>(C(<span class="php-quote">'REQUEST_VARS_FILTER'</span>)){ <span class="php-keyword2">array_walk_recursive</span>(<span class="php-var">$_GET</span>, <span class="php-quote">'think_filter'</span>); <span class="php-keyword2">array_walk_recursive</span>(<span class="php-var">$_POST</span>, <span class="php-quote">'think_filter'</span>); <span class="php-keyword2">array_walk_recursive</span>(<span class="php-var">$_REQUEST</span>, <span class="php-quote">'think_filter'</span>); } Hook::listen(<span class="php-quote">'url_dispatch'</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'IS_AJAX'</span>, ((<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_X_REQUESTED_WITH'</span>]) &amp;&amp; <span class="php-keyword2">strtolower</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_X_REQUESTED_WITH'</span>]) == <span class="php-quote">'xmlhttprequest'</span>) || !<span class="php-keyword1">empty</span>(<span class="php-var">$_POST</span>[C(<span class="php-quote">'VAR_AJAX_SUBMIT'</span>)]) || !<span class="php-keyword1">empty</span>(<span class="php-var">$_GET</span>[C(<span class="php-quote">'VAR_AJAX_SUBMIT'</span>)])) ? <span class="php-keyword1">true</span> : <span class="php-keyword1">false</span>); C(<span class="php-quote">'TMPL_EXCEPTION_FILE'</span>,<span class="php-keyword2">realpath</span>(C(<span class="php-quote">'TMPL_EXCEPTION_FILE'</span>))); <span class="php-keyword1">return</span> ; } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> <span class="php-keyword2">exec</span>() { <span class="php-keyword1">if</span>(!<span class="php-keyword2">preg_match</span>(<span class="php-quote">'/^[A-Za-z](\/|\w)*$/'</span>,CONTROLLER_NAME)){ <span class="php-var">$module</span> = <span class="php-keyword1">false</span>; }<span class="php-keyword1">elseif</span>(C(<span class="php-quote">'ACTION_BIND_CLASS'</span>)){ <span class="php-var">$layer</span> = C(<span class="php-quote">'DEFAULT_C_LAYER'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_dir</span>(MODULE_PATH.<span class="php-var">$layer</span>.<span class="php-quote">'/'</span>.CONTROLLER_NAME)){ <span class="php-var">$namespace</span> = MODULE_NAME.<span class="php-quote">'\\'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'\\'</span>.CONTROLLER_NAME.<span class="php-quote">'\\'</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$namespace</span> = MODULE_NAME.<span class="php-quote">'\\'</span>.<span class="php-var">$layer</span>.<span class="php-quote">'\\_empty\\'</span>; } <span class="php-var">$actionName</span> = <span class="php-keyword2">strtolower</span>(ACTION_NAME); <span class="php-keyword1">if</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$namespace</span>.<span class="php-var">$actionName</span>)){ <span class="php-var">$class</span> = <span class="php-var">$namespace</span>.<span class="php-var">$actionName</span>; }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$namespace</span>.<span class="php-quote">'_empty'</span>)){ <span class="php-var">$class</span> = <span class="php-var">$namespace</span>.<span class="php-quote">'_empty'</span>; }<span class="php-keyword1">else</span>{ E(L(<span class="php-quote">'_ERROR_ACTION_'</span>).<span class="php-quote">':'</span>.ACTION_NAME); } <span class="php-var">$module</span> = <span class="php-keyword1">new</span> <span class="php-var">$class</span>; <span class="php-var">$action</span> = <span class="php-quote">'run'</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$module</span> = controller(CONTROLLER_NAME,CONTROLLER_PATH); } <span class="php-keyword1">if</span>(!<span class="php-var">$module</span>) { <span class="php-keyword1">if</span>(<span class="php-quote">'4e5e5d7364f443e28fbf0d3ae744a59a'</span> == CONTROLLER_NAME) { <span class="php-keyword2">header</span>(<span class="php-quote">&quot;Content-type:image/png&quot;</span>); <span class="php-keyword1">exit</span>(<span class="php-keyword2">base64_decode</span>(App::logo())); } <span class="php-var">$module</span> = A(<span class="php-quote">'Empty'</span>); <span class="php-keyword1">if</span>(!<span class="php-var">$module</span>){ E(L(<span class="php-quote">'_CONTROLLER_NOT_EXIST_'</span>).<span class="php-quote">':'</span>.CONTROLLER_NAME); } } <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$action</span>)){ <span class="php-var">$action</span> = ACTION_NAME.C(<span class="php-quote">'ACTION_SUFFIX'</span>); } <span class="php-keyword1">try</span>{ self::invokeAction(<span class="php-var">$module</span>,<span class="php-var">$action</span>); } <span class="php-keyword1">catch</span> (\ReflectionException <span class="php-var">$e</span>) { <span class="php-var">$method</span> = <span class="php-keyword1">new</span> \ReflectionMethod(<span class="php-var">$module</span>,<span class="php-quote">'__call'</span>); <span class="php-var">$method</span>-&gt;invokeArgs(<span class="php-var">$module</span>,<span class="php-keyword1">array</span>(<span class="php-var">$action</span>,<span class="php-quote">''</span>)); } <span class="php-keyword1">return</span> ; } <span class="php-keyword1">public</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> invokeAction(<span class="php-var">$module</span>,<span class="php-var">$action</span>){ <span class="php-keyword1">if</span>(!<span class="php-keyword2">preg_match</span>(<span class="php-quote">'/^[A-Za-z](\w)*$/'</span>,<span class="php-var">$action</span>)){ <span class="php-keyword1">throw</span> <span class="php-keyword1">new</span> \ReflectionException(); } <span class="php-var">$method</span> = <span class="php-keyword1">new</span> \ReflectionMethod(<span class="php-var">$module</span>, <span class="php-var">$action</span>); <span class="php-keyword1">if</span>(<span class="php-var">$method</span>-&gt;isPublic() &amp;&amp; !<span class="php-var">$method</span>-&gt;isStatic()) { <span class="php-var">$class</span> = <span class="php-keyword1">new</span> \ReflectionClass(<span class="php-var">$module</span>); <span class="php-keyword1">if</span>(<span class="php-var">$class</span>-&gt;hasMethod(<span class="php-quote">'_before_'</span>.<span class="php-var">$action</span>)) { <span class="php-var">$before</span> = <span class="php-var">$class</span>-&gt;getMethod(<span class="php-quote">'_before_'</span>.<span class="php-var">$action</span>); <span class="php-keyword1">if</span>(<span class="php-var">$before</span>-&gt;isPublic()) { <span class="php-var">$before</span>-&gt;invoke(<span class="php-var">$module</span>); } } <span class="php-keyword1">if</span>(<span class="php-var">$method</span>-&gt;getNumberOfParameters()&gt;<span class="php-num">0</span> &amp;&amp; C(<span class="php-quote">'URL_PARAMS_BIND'</span>)){ <span class="php-keyword1">switch</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'REQUEST_METHOD'</span>]) { <span class="php-keyword1">case</span> <span class="php-quote">'POST'</span>: <span class="php-var">$vars</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_GET</span>,<span class="php-var">$_POST</span>); <span class="php-keyword1">break</span>; <span class="php-keyword1">case</span> <span class="php-quote">'PUT'</span>: <span class="php-keyword2">parse_str</span>(<span class="php-keyword2">file_get_contents</span>(<span class="php-quote">'php://input'</span>), <span class="php-var">$vars</span>); <span class="php-keyword1">break</span>; <span class="php-keyword1">default</span>: <span class="php-var">$vars</span> = <span class="php-var">$_GET</span>; } <span class="php-var">$params</span> = <span class="php-var">$method</span>-&gt;getParameters(); <span class="php-var">$paramsBindType</span> = C(<span class="php-quote">'URL_PARAMS_BIND_TYPE'</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$params</span> <span class="php-keyword1">as</span> <span class="php-var">$param</span>){ <span class="php-var">$name</span> = <span class="php-var">$param</span>-&gt;getName(); <span class="php-keyword1">if</span>( <span class="php-num">1</span> == <span class="php-var">$paramsBindType</span> &amp;&amp; !<span class="php-keyword1">empty</span>(<span class="php-var">$vars</span>) ){ <span class="php-var">$args</span>[] = <span class="php-keyword2">array_shift</span>(<span class="php-var">$vars</span>); }<span class="php-keyword1">elseif</span>( <span class="php-num">0</span> == <span class="php-var">$paramsBindType</span> &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$vars</span>[<span class="php-var">$name</span>])){ <span class="php-var">$args</span>[] = <span class="php-var">$vars</span>[<span class="php-var">$name</span>]; }<span class="php-keyword1">elseif</span>(<span class="php-var">$param</span>-&gt;isDefaultValueAvailable()){ <span class="php-var">$args</span>[] = <span class="php-var">$param</span>-&gt;getDefaultValue(); }<span class="php-keyword1">else</span>{ E(L(<span class="php-quote">'_PARAM_ERROR_'</span>).<span class="php-quote">':'</span>.<span class="php-var">$name</span>); } } <span class="php-keyword1">if</span>(C(<span class="php-quote">'URL_PARAMS_SAFE'</span>)){ <span class="php-var">$filters</span> = C(<span class="php-quote">'URL_PARAMS_FILTER'</span>)?:C(<span class="php-quote">'DEFAULT_FILTER'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$filters</span>) { <span class="php-var">$filters</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,<span class="php-var">$filters</span>); <span class="php-keyword1">foreach</span>(<span class="php-var">$filters</span> <span class="php-keyword1">as</span> <span class="php-var">$filter</span>){ <span class="php-var">$args</span> = array_map_recursive(<span class="php-var">$filter</span>,<span class="php-var">$args</span>); } } } <span class="php-keyword2">array_walk_recursive</span>(<span class="php-var">$args</span>,<span class="php-quote">'think_filter'</span>); <span class="php-var">$method</span>-&gt;invokeArgs(<span class="php-var">$module</span>,<span class="php-var">$args</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$method</span>-&gt;invoke(<span class="php-var">$module</span>); } <span class="php-keyword1">if</span>(<span class="php-var">$class</span>-&gt;hasMethod(<span class="php-quote">'_after_'</span>.<span class="php-var">$action</span>)) { <span class="php-var">$after</span> = <span class="php-var">$class</span>-&gt;getMethod(<span class="php-quote">'_after_'</span>.<span class="php-var">$action</span>); <span class="php-keyword1">if</span>(<span class="php-var">$after</span>-&gt;isPublic()) { <span class="php-var">$after</span>-&gt;invoke(<span class="php-var">$module</span>); } } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">throw</span> <span class="php-keyword1">new</span> \ReflectionException(); } } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> run() { Hook::listen(<span class="php-quote">'app_init'</span>); App::init(); Hook::listen(<span class="php-quote">'app_begin'</span>); <span class="php-keyword1">if</span>(!IS_CLI){ session(C(<span class="php-quote">'SESSION_OPTIONS'</span>)); } G(<span class="php-quote">'initTime'</span>); App::<span class="php-keyword2">exec</span>(); Hook::listen(<span class="php-quote">'app_end'</span>); <span class="php-keyword1">return</span> ; } <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> logo(){ <span class="php-keyword1">return</span> <span class="php-quote">'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjVERDVENkZGQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjVERDVENzAwQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NURENUQ2RkRCOTI0MTFFMTlERjdENDlFNDZFNENBQkIiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NURENUQ2RkVCOTI0MTFFMTlERjdENDlFNDZFNENBQkIiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5fx6IRAAAMCElEQVR42sxae3BU1Rk/9+69+8xuNtkHJAFCSIAkhMgjCCJQUi0GtEIVbP8Qq9LH2No6TmfaztjO2OnUdvqHFMfOVFTqIK0vUEEeqUBARCsEeYQkEPJoEvIiELLvvc9z+p27u2F3s5tsBB1OZiebu5dzf7/v/L7f952zMM8cWIwY+Mk2ulCp92Fnq3XvnzArr2NZnYNldDp0Gw+/OEQ4+obQn5D+4Ubb22+YOGsWi/Todh8AHglKEGkEsnHBQ162511GZFgW6ZCBM9/W4H3iNSQqIe09O196dLKX7d1O39OViP/wthtkND62if/wj/DbMpph8BY/m9xy8BoBmQk+mHqZQGNy4JYRwCoRbwa8l4JXw6M+orJxpU0U6ToKy/5bQsAiTeokGKkTx46RRxxEUgrwGgF4MWNNEJCGgYTvpgnY1IJWg5RzfqLgvcIgktX0i8dmMlFA8qCQ5L0Z/WObPLUxT1i4lWSYDISoEfBYGvM+LlMQQdkLHoWRRZ8zYQI62Thswe5WTORGwNXDcGjqeOA9AF7B8rhzsxMBEoJ8oJKaqPu4hblHMCMPwl9XeNWyb8xkB/DDGYKfMAE6aFL7xesZ389JlgG3XHEMI6UPDOP6JHHu67T2pwNPI69mCP4rEaBDUAJaKc/AOuXiwH07VCS3w5+UQMAuF/WqGI+yFIwVNBwemBD4r0wgQiKoFZa00sEYTwss32lA1tPwVxtc8jQ5/gWCwmGCyUD8vRT0sHBFW4GJDvZmrJFWRY1EkrGA6ZB8/10fOZSSj0E6F+BSP7xidiIzhBmKB09lEwHPkG+UQIyEN44EBiT5vrv2uJXyPQqSqO930fxvcvwbR/+JAkD9EfASgI9EHlp6YiHO4W+cAB20SnrFqxBbNljiXf1Pl1K2S0HCWfiog3YlAD5RGwwxK6oUjTweuVigLjyB0mX410mAFnMoVK1lvvUvgt8fUJH0JVyjuvcmg4dE5mUiFtD24AZ4qBVELxXKS+pMxN43kSdzNwudJ+bQbLlmnxvPOQoCugSap1GnSRoG8KOiKbH+rIA0lEeSAg3y6eeQ6XI2nrYnrPM89bUTgI0Pdqvl50vlNbtZxDUBcLBK0kPd5jPziyLdojJIN0pq5/mdzwL4UVvVInV5ncQEPNOUxa9d0TU+CW5l+FoI0GSDKHVVSOs+0KOsZoxwOzSZNFGv0mQ9avyLCh2Hpm+70Y0YJoJVgmQv822wnDC8Miq6VjJ5IFed0QD1YiAbT+nQE8v/RMZfmgmcCRHIIu7Bmcp39oM9fqEychcA747KxQ/AEyqQonl7hATtJmnhO2XYtgcia01aSbVMenAXrIomPcLgEBA4liGBzFZAT8zBYqW6brI67wg8sFVhxBhwLwBP2+tqBQqqK7VJKGh/BRrfTr6nWL7nYBaZdBJHqrX3kPEPap56xwE/GvjJTRMADeMCdcGpGXL1Xh4ZL8BDOlWkUpegfi0CeDzeA5YITzEnddv+IXL+UYCmqIvqC9UlUC/ki9FipwVjunL3yX7dOTLeXmVMAhbsGporPfyOBTm/BJ23gTVehsvXRnSewagUfpBXF3p5pygKS7OceqTjb7h2vjr/XKm0ZofKSI2Q/J102wHzatZkJPYQ5JoKsuK+EoHJakVzubzuLQDepCKllTZi9AG0DYg9ZLxhFaZsOu7bvlmVI5oPXJMQJcHxHClSln1apFTvAimeg48u0RWFeZW4lVcjbQWZuIQK1KozZfIDO6CSQmQQXdpBaiKZyEWThVK1uEc6v7V7uK0ysduExPZx4vysDR+4SelhBYm0R6LBuR4PXts8MYMcJPsINo4YZCDLj0sgB0/vLpPXvA2Tn42Cv5rsLulGubzW0sEd3d4W/mJt2Kck+DzDMijfPLOjyrDhXSh852B+OvflqAkoyXO1cYfujtc/i3jJSAwhgfFlp20laMLOku/bC7prgqW7lCn4auE5NhcXPd3M7x70+IceSgZvNljCd9k3fLjYsPElqLR14PXQZqD2ZNkkrAB79UeJUebFQmXpf8ZcAQt2XrMQdyNUVBqZoUzAFyp3V3xi/MubUA/mCT4Fhf038PC8XplhWnCmnK/ZzyC2BSTRSqKVOuY2kB8Jia0lvvRIVoP+vVWJbYarf6p655E2/nANBMCWkgD49DA0VAMyI1OLFMYCXiU9bmzi9/y5i/vsaTpHPHidTofzLbM65vMPva9HlovgXp0AvjtaqYMfDD0/4mAsYE92pxa+9k1QgCnRVObCpojpzsKTPvayPetTEgBdwnssjuc0kOBFX+q3HwRQxdrOLAqeYRjkMk/trTSu2Z9Lik7CfF0AvjtqAhS4NHobGXUnB5DQs8hG8p/wMX1r4+8xkmyvQ50JVq72TVeXbz3HvpWaQJi57hJYTw4kGbtS+C2TigQUtZUX+X27QQq2ePBZBru/0lxTm8fOOQ5yaZOZMAV+he4FqIMB+LQB0UgMSajANX29j+vbmly8ipRvHeSQoQOkM5iFXcPQCVwDMs5RBCQmaPOyvbNd6uwvQJ183BZQG3Zc+Eiv7vQOKu8YeDmMcJlt2ckyftVeMIGLBCmdMHl/tFILYwGPjXWO3zOfSq/+om+oa7Mlh2fpSsRGLp7RAW3FUVjNHgiMhyE6zBFjM2BdkdJGO7nP1kJXWAtBuBpPIAu7f+hhu7bFXIuC5xWrf0X2xreykOsUyKkF2gwadbrXDcXrfKxR43zGcSj4t/cCgr+a1iy6EjE5GYktUCl9fwfMeylyooGF48bN2IGLTw8x7StS7sj8TF9FmPGWQhm3rRR+o9lhvjJvSYAdfDUevI1M6bnX/OwWaDMOQ8RPgKRo0eulBTdT8AW2kl8e9L7UHghHwMfLiZPNoSpx0yugpQZaFqKWqxVSM3a2pN1SAhC2jf94I7ybBI7EL5A2Wvu5ht3xsoEt4+Ay/abXgCQAxyOeDsDlTCQzy75ohcGgv9Tra9uiymRUYTLrswOLlCdfAQf7HPDQQ4ErAH5EDXB9cMxWYpjtXApRncojS0sbV/cCgHTHwGNBJy+1PQE2x56FpaVR7wfQGZ37V+V+19EiHNvR6q1fRUjqvbjbMq1/qfHxbTrE10ePY2gPFk48D2CVMTf1AF4PXvyYR9dV6Wf7H413m3xTWQvYGhQ7mfYwA5mAX+18Vue05v/8jG/fZX/IW5MKPKtjSYlt0ellxh+/BOCPAwYaeVr0QofZFxJWVWC8znG70au6llVmktsF0bfHF6k8fvZ5esZJbwHwwnjg59tXz6sL/P0NUZDuSNu1mnJ8Vab17+cy005A9wtOpp3i0bZdpJLUil00semAwN45LgEViZYe3amNye0B6A9chviSlzXVsFtyN5/1H3gaNmMpn8Fz0GpYFp6Zw615H/LpUuRQQDMCL82n5DpBSawkvzIdN2ypiT8nSLth8Pk9jnjwdFzH3W4XW6KMBfwB569NdcGX93mC16tTflcArcYUc/mFuYbV+8zY0SAjAVoNErNgWjtwumJ3wbn/HlBFYdxHvSkJJEc+Ngal9opSwyo9YlITX2C/P/+gf8sxURSLR+mcZUmeqaS9wrh6vxW5zxFCOqFi90RbDWq/YwZmnu1+a6OvdpvRqkNxxe44lyl4OobEnpKA6Uox5EfH9xzPs/HRKrTPWdIQrK1VZDU7ETiD3Obpl+8wPPCRBbkbwNtpW9AbBe5L1SMlj3tdTxk/9W47JUmqS5HU+JzYymUKXjtWVmT9RenIhgXc+nroWLyxXJhmL112OdB8GCsk4f8oZJucnvmmtR85mBn10GZ0EKSCMUSAR3ukcXd5s7LvLD3me61WkuTCpJzYAyRurMB44EdEJzTfU271lUJC03YjXJXzYOGZwN4D8eB5jlfLrdWfzGRW7icMPfiSO6Oe7s20bmhdgLX4Z23B+s3JgQESzUDiMboSzDMHFpNMwccGePauhfwjzwnI2wu9zKGgEFg80jcZ7MHllk07s1H+5yojtUQTlH4nFdLKTGwDmPbIklOb1L1zO4T6N8NCuDLFLS/C63c0eNRimZ++s5BMBHxU11jHchI9oFVUxRh/eMDzHEzGYu0Lg8gJ7oS/tFCwoic44fyUtix0n/46vP4bf+//BRgAYwDDar4ncHIAAAAASUVORK5CYII='</span>; } }}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">class</span> Dispatcher { <span class="php-keyword1">static</span> <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> dispatch() { <span class="php-var">$varPath</span> = C(<span class="php-quote">'VAR_PATHINFO'</span>); <span class="php-var">$varAddon</span> = C(<span class="php-quote">'VAR_ADDON'</span>); <span class="php-var">$varModule</span> = C(<span class="php-quote">'VAR_MODULE'</span>); <span class="php-var">$varController</span> = C(<span class="php-quote">'VAR_CONTROLLER'</span>); <span class="php-var">$varAction</span> = C(<span class="php-quote">'VAR_ACTION'</span>); <span class="php-var">$urlCase</span> = C(<span class="php-quote">'URL_CASE_INSENSITIVE'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$varPath</span>])) { <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-var">$_GET</span>[<span class="php-var">$varPath</span>]; <span class="php-keyword1">unset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$varPath</span>]); }<span class="php-keyword1">elseif</span>(IS_CLI){ <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'argv'</span>][<span class="php-num">1</span>]) ? <span class="php-var">$_SERVER</span>[<span class="php-quote">'argv'</span>][<span class="php-num">1</span>] : <span class="php-quote">''</span>; } <span class="php-keyword1">if</span>(C(<span class="php-quote">'APP_SUB_DOMAIN_DEPLOY'</span>)) { <span class="php-var">$rules</span> = C(<span class="php-quote">'APP_SUB_DOMAIN_RULES'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$rules</span>[<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>]])) { <span class="php-keyword2">define</span>(<span class="php-quote">'APP_DOMAIN'</span>,<span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>]); <span class="php-var">$rule</span> = <span class="php-var">$rules</span>[APP_DOMAIN]; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(C(<span class="php-quote">'APP_DOMAIN_SUFFIX'</span>),<span class="php-quote">'.'</span>)){ <span class="php-var">$domain</span> = <span class="php-keyword2">array_slice</span>(<span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>]), <span class="php-num">0</span>, -<span class="php-num">3</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$domain</span> = <span class="php-keyword2">array_slice</span>(<span class="php-keyword2">explode</span>(<span class="php-quote">'.'</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'HTTP_HOST'</span>]), <span class="php-num">0</span>, -<span class="php-num">2</span>); } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$domain</span>)) { <span class="php-var">$subDomain</span> = <span class="php-keyword2">implode</span>(<span class="php-quote">'.'</span>, <span class="php-var">$domain</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'SUB_DOMAIN'</span>,<span class="php-var">$subDomain</span>); <span class="php-var">$domain2</span> = <span class="php-keyword2">array_pop</span>(<span class="php-var">$domain</span>); <span class="php-keyword1">if</span>(<span class="php-var">$domain</span>) { <span class="php-var">$domain3</span> = <span class="php-keyword2">array_pop</span>(<span class="php-var">$domain</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$rules</span>[<span class="php-var">$subDomain</span>])) { <span class="php-var">$rule</span> = <span class="php-var">$rules</span>[<span class="php-var">$subDomain</span>]; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$rules</span>[<span class="php-quote">'*.'</span> . <span class="php-var">$domain2</span>]) &amp;&amp; !<span class="php-keyword1">empty</span>(<span class="php-var">$domain3</span>)){ <span class="php-var">$rule</span> = <span class="php-var">$rules</span>[<span class="php-quote">'*.'</span> . <span class="php-var">$domain2</span>]; <span class="php-var">$panDomain</span> = <span class="php-var">$domain3</span>; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$rules</span>[<span class="php-quote">'*'</span>]) &amp;&amp; !<span class="php-keyword1">empty</span>(<span class="php-var">$domain2</span>) &amp;&amp; <span class="php-quote">'www'</span> != <span class="php-var">$domain2</span> ){ <span class="php-var">$rule</span> = <span class="php-var">$rules</span>[<span class="php-quote">'*'</span>]; <span class="php-var">$panDomain</span> = <span class="php-var">$domain2</span>; } } } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$rule</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$rule</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$rule</span>,<span class="php-var">$vars</span>) = <span class="php-var">$rule</span>; } <span class="php-var">$array</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$rule</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'BIND_MODULE'</span>,<span class="php-keyword2">array_shift</span>(<span class="php-var">$array</span>)); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$array</span>)) { <span class="php-var">$controller</span> = <span class="php-keyword2">array_shift</span>(<span class="php-var">$array</span>); <span class="php-keyword1">if</span>(<span class="php-var">$controller</span>){ <span class="php-keyword2">define</span>(<span class="php-quote">'BIND_CONTROLLER'</span>,<span class="php-var">$controller</span>); } } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$vars</span>)) { <span class="php-keyword2">parse_str</span>(<span class="php-var">$vars</span>,<span class="php-var">$parms</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$panDomain</span>)){ <span class="php-var">$pos</span> = <span class="php-keyword2">array_search</span>(<span class="php-quote">'*'</span>, <span class="php-var">$parms</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-var">$pos</span>) { <span class="php-var">$parms</span>[<span class="php-var">$pos</span>] = <span class="php-var">$panDomain</span>; } } <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_GET</span>,<span class="php-var">$parms</span>); } } } <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>])) { <span class="php-var">$types</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,C(<span class="php-quote">'URL_PATHINFO_FETCH'</span>)); <span class="php-keyword1">foreach</span> (<span class="php-var">$types</span> <span class="php-keyword1">as</span> <span class="php-var">$type</span>){ <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$type</span>,<span class="php-quote">':'</span>)) { <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-keyword2">call_user_func</span>(<span class="php-keyword2">substr</span>(<span class="php-var">$type</span>,<span class="php-num">1</span>)); <span class="php-keyword1">break</span>; }<span class="php-keyword1">elseif</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$_SERVER</span>[<span class="php-var">$type</span>])) { <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = (<span class="php-num">0</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$_SERVER</span>[<span class="php-var">$type</span>],<span class="php-var">$_SERVER</span>[<span class="php-quote">'SCRIPT_NAME'</span>]))? <span class="php-keyword2">substr</span>(<span class="php-var">$_SERVER</span>[<span class="php-var">$type</span>], <span class="php-keyword2">strlen</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'SCRIPT_NAME'</span>])) : <span class="php-var">$_SERVER</span>[<span class="php-var">$type</span>]; <span class="php-keyword1">break</span>; } } } <span class="php-var">$depr</span> = C(<span class="php-quote">'URL_PATHINFO_DEPR'</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'MODULE_PATHINFO_DEPR'</span>, <span class="php-var">$depr</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>])) { <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-quote">''</span>; <span class="php-keyword2">define</span>(<span class="php-quote">'__INFO__'</span>,<span class="php-quote">''</span>); <span class="php-keyword2">define</span>(<span class="php-quote">'__EXT__'</span>,<span class="php-quote">''</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword2">define</span>(<span class="php-quote">'__INFO__'</span>,<span class="php-keyword2">trim</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>],<span class="php-quote">'/'</span>)); <span class="php-keyword2">define</span>(<span class="php-quote">'__EXT__'</span>, <span class="php-keyword2">strtolower</span>(<span class="php-keyword2">pathinfo</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>],PATHINFO_EXTENSION))); <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = __INFO__; <span class="php-keyword1">if</span>(!<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_MODULE'</span>) &amp;&amp; (!C(<span class="php-quote">'URL_ROUTER_ON'</span>) || !Route::check())){ <span class="php-keyword1">if</span> (__INFO__ &amp;&amp; C(<span class="php-quote">'MULTI_MODULE'</span>)){ <span class="php-var">$paths</span> = <span class="php-keyword2">explode</span>(<span class="php-var">$depr</span>,__INFO__,<span class="php-num">2</span>); <span class="php-var">$allowList</span> = C(<span class="php-quote">'MODULE_ALLOW_LIST'</span>); <span class="php-var">$module</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/\.'</span> . __EXT__ . <span class="php-quote">'$/i'</span>, <span class="php-quote">''</span>,<span class="php-var">$paths</span>[<span class="php-num">0</span>]); <span class="php-keyword1">if</span>( <span class="php-keyword1">empty</span>(<span class="php-var">$allowList</span>) || (<span class="php-keyword2">is_array</span>(<span class="php-var">$allowList</span>) &amp;&amp; in_array_case(<span class="php-var">$module</span>, <span class="php-var">$allowList</span>))){ <span class="php-var">$_GET</span>[<span class="php-var">$varModule</span>] = <span class="php-var">$module</span>; <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-keyword1">isset</span>(<span class="php-var">$paths</span>[<span class="php-num">1</span>])?<span class="php-var">$paths</span>[<span class="php-num">1</span>]:<span class="php-quote">''</span>; } } } } <span class="php-keyword2">define</span>(<span class="php-quote">'__SELF__'</span>,<span class="php-keyword2">strip_tags</span>(<span class="php-var">$_SERVER</span>[C(<span class="php-quote">'URL_REQUEST_URI'</span>)])); <span class="php-keyword2">define</span>(<span class="php-quote">'MODULE_NAME'</span>, <span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_MODULE'</span>)? BIND_MODULE : self::getModule(<span class="php-var">$varModule</span>)); <span class="php-keyword1">if</span>( MODULE_NAME &amp;&amp; (<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_MODULE'</span>) || !in_array_case(MODULE_NAME,C(<span class="php-quote">'MODULE_DENY_LIST'</span>)) ) &amp;&amp; <span class="php-keyword2">is_dir</span>(APP_PATH.MODULE_NAME)){ <span class="php-keyword2">define</span>(<span class="php-quote">'MODULE_PATH'</span>, APP_PATH.MODULE_NAME.<span class="php-quote">'/'</span>); C(<span class="php-quote">'CACHE_PATH'</span>,CACHE_PATH.MODULE_NAME.<span class="php-quote">'/'</span>); C(<span class="php-quote">'LOG_PATH'</span>, <span class="php-keyword2">realpath</span>(LOG_PATH).<span class="php-quote">'/'</span>.MODULE_NAME.<span class="php-quote">'/'</span>); Hook::listen(<span class="php-quote">'module_check'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Conf/config'</span>.CONF_EXT)) C(load_config(MODULE_PATH.<span class="php-quote">'Conf/config'</span>.CONF_EXT)); <span class="php-keyword1">if</span>(<span class="php-quote">'common'</span> != APP_MODE &amp;&amp; <span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Conf/config_'</span>.APP_MODE.CONF_EXT)) C(load_config(MODULE_PATH.<span class="php-quote">'Conf/config_'</span>.APP_MODE.CONF_EXT)); <span class="php-keyword1">if</span>(APP_STATUS &amp;&amp; <span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Conf/'</span>.APP_STATUS.CONF_EXT)) C(load_config(MODULE_PATH.<span class="php-quote">'Conf/'</span>.APP_STATUS.CONF_EXT)); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Conf/alias.php'</span>)) Think::addMap(<span class="php-keyword1">include</span> MODULE_PATH.<span class="php-quote">'Conf/alias.php'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Conf/tags.php'</span>)) Hook::import(<span class="php-keyword1">include</span> MODULE_PATH.<span class="php-quote">'Conf/tags.php'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(MODULE_PATH.<span class="php-quote">'Common/function.php'</span>)) <span class="php-keyword1">include</span> MODULE_PATH.<span class="php-quote">'Common/function.php'</span>; <span class="php-var">$urlCase</span> = C(<span class="php-quote">'URL_CASE_INSENSITIVE'</span>); load_ext_file(MODULE_PATH); }<span class="php-keyword1">else</span>{ E(L(<span class="php-quote">'_MODULE_NOT_EXIST_'</span>).<span class="php-quote">':'</span>.MODULE_NAME); } <span class="php-keyword1">if</span>(!<span class="php-keyword2">defined</span>(<span class="php-quote">'__APP__'</span>)){ <span class="php-var">$urlMode</span> = C(<span class="php-quote">'URL_MODEL'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$urlMode</span> == URL_COMPAT ){ <span class="php-keyword2">define</span>(<span class="php-quote">'PHP_FILE'</span>,_PHP_FILE_.<span class="php-quote">'?'</span>.<span class="php-var">$varPath</span>.<span class="php-quote">'='</span>); }<span class="php-keyword1">elseif</span>(<span class="php-var">$urlMode</span> == URL_REWRITE ) { <span class="php-var">$url</span> = <span class="php-keyword2">dirname</span>(_PHP_FILE_); <span class="php-keyword1">if</span>(<span class="php-var">$url</span> == <span class="php-quote">'/'</span> || <span class="php-var">$url</span> == <span class="php-quote">'\\'</span>) <span class="php-var">$url</span> = <span class="php-quote">''</span>; <span class="php-keyword2">define</span>(<span class="php-quote">'PHP_FILE'</span>,<span class="php-var">$url</span>); }<span class="php-keyword1">else</span> { <span class="php-keyword2">define</span>(<span class="php-quote">'PHP_FILE'</span>,_PHP_FILE_); } <span class="php-keyword2">define</span>(<span class="php-quote">'__APP__'</span>,<span class="php-keyword2">strip_tags</span>(PHP_FILE)); } <span class="php-var">$moduleName</span> = <span class="php-keyword2">defined</span>(<span class="php-quote">'MODULE_ALIAS'</span>)? MODULE_ALIAS : MODULE_NAME; <span class="php-keyword2">define</span>(<span class="php-quote">'__MODULE__'</span>,(<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_MODULE'</span>) || !C(<span class="php-quote">'MULTI_MODULE'</span>))? __APP__ : __APP__.<span class="php-quote">'/'</span>.(<span class="php-var">$urlCase</span> ? <span class="php-keyword2">strtolower</span>(<span class="php-var">$moduleName</span>) : <span class="php-var">$moduleName</span>)); <span class="php-keyword1">if</span>(<span class="php-quote">''</span> != <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] &amp;&amp; (!C(<span class="php-quote">'URL_ROUTER_ON'</span>) || !Route::check()) ){ Hook::listen(<span class="php-quote">'path_info'</span>); <span class="php-keyword1">if</span>(C(<span class="php-quote">'URL_DENY_SUFFIX'</span>) &amp;&amp; <span class="php-keyword2">preg_match</span>(<span class="php-quote">'/\.('</span>.<span class="php-keyword2">trim</span>(C(<span class="php-quote">'URL_DENY_SUFFIX'</span>),<span class="php-quote">'.'</span>).<span class="php-quote">')$/i'</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>])){ send_http_status(<span class="php-num">404</span>); <span class="php-keyword1">exit</span>; } <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>] = <span class="php-keyword2">preg_replace</span>(C(<span class="php-quote">'URL_HTML_SUFFIX'</span>)? <span class="php-quote">'/\.('</span>.<span class="php-keyword2">trim</span>(C(<span class="php-quote">'URL_HTML_SUFFIX'</span>),<span class="php-quote">'.'</span>).<span class="php-quote">')$/i'</span> : <span class="php-quote">'/\.'</span>.__EXT__.<span class="php-quote">'$/i'</span>, <span class="php-quote">''</span>, <span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>]); <span class="php-var">$depr</span> = C(<span class="php-quote">'URL_PATHINFO_DEPR'</span>); <span class="php-var">$paths</span> = <span class="php-keyword2">explode</span>(<span class="php-var">$depr</span>,<span class="php-keyword2">trim</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>],<span class="php-var">$depr</span>)); <span class="php-keyword1">if</span>(!<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_CONTROLLER'</span>)) { <span class="php-keyword1">if</span>(C(<span class="php-quote">'CONTROLLER_LEVEL'</span>)&gt;<span class="php-num">1</span>){ <span class="php-var">$_GET</span>[<span class="php-var">$varController</span>] = <span class="php-keyword2">implode</span>(<span class="php-quote">'/'</span>,<span class="php-keyword2">array_slice</span>(<span class="php-var">$paths</span>,<span class="php-num">0</span>,C(<span class="php-quote">'CONTROLLER_LEVEL'</span>))); <span class="php-var">$paths</span> = <span class="php-keyword2">array_slice</span>(<span class="php-var">$paths</span>, C(<span class="php-quote">'CONTROLLER_LEVEL'</span>)); }<span class="php-keyword1">else</span>{ <span class="php-var">$_GET</span>[<span class="php-var">$varController</span>] = <span class="php-keyword2">array_shift</span>(<span class="php-var">$paths</span>); } } <span class="php-keyword1">if</span>(!<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_ACTION'</span>)){ <span class="php-var">$_GET</span>[<span class="php-var">$varAction</span>] = <span class="php-keyword2">array_shift</span>(<span class="php-var">$paths</span>); } <span class="php-var">$var</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(C(<span class="php-quote">'URL_PARAMS_BIND'</span>) &amp;&amp; <span class="php-num">1</span> == C(<span class="php-quote">'URL_PARAMS_BIND_TYPE'</span>)){ <span class="php-var">$var</span> = <span class="php-var">$paths</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/(\w+)\/([^\/]+)/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>) <span class="php-keyword1">use</span>(&amp;<span class="php-var">$var</span>){<span class="php-var">$var</span>[<span class="php-var">$match</span>[<span class="php-num">1</span>]]=<span class="php-keyword2">strip_tags</span>(<span class="php-var">$match</span>[<span class="php-num">2</span>]);}, <span class="php-keyword2">implode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$paths</span>)); } <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>,<span class="php-var">$_GET</span>); } <span class="php-keyword2">define</span>(<span class="php-quote">'CONTROLLER_PATH'</span>, self::getSpace(<span class="php-var">$varAddon</span>,<span class="php-var">$urlCase</span>)); <span class="php-keyword2">define</span>(<span class="php-quote">'CONTROLLER_NAME'</span>, <span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_CONTROLLER'</span>)? BIND_CONTROLLER : self::getController(<span class="php-var">$varController</span>,<span class="php-var">$urlCase</span>)); <span class="php-keyword2">define</span>(<span class="php-quote">'ACTION_NAME'</span>, <span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_ACTION'</span>)? BIND_ACTION : self::getAction(<span class="php-var">$varAction</span>,<span class="php-var">$urlCase</span>)); <span class="php-var">$controllerName</span> = <span class="php-keyword2">defined</span>(<span class="php-quote">'CONTROLLER_ALIAS'</span>)? CONTROLLER_ALIAS : CONTROLLER_NAME; <span class="php-keyword2">define</span>(<span class="php-quote">'__CONTROLLER__'</span>,__MODULE__.<span class="php-var">$depr</span>.(<span class="php-keyword2">defined</span>(<span class="php-quote">'BIND_CONTROLLER'</span>)? <span class="php-quote">''</span>: ( <span class="php-var">$urlCase</span> ? parse_name(<span class="php-var">$controllerName</span>) : <span class="php-var">$controllerName</span> )) ); <span class="php-keyword2">define</span>(<span class="php-quote">'__ACTION__'</span>,__CONTROLLER__.<span class="php-var">$depr</span>.(<span class="php-keyword2">defined</span>(<span class="php-quote">'ACTION_ALIAS'</span>)?ACTION_ALIAS:ACTION_NAME)); <span class="php-var">$_REQUEST</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_POST</span>,<span class="php-var">$_GET</span>,<span class="php-var">$_COOKIE</span>); } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> getSpace(<span class="php-var">$var</span>,<span class="php-var">$urlCase</span>) { <span class="php-var">$space</span> = !<span class="php-keyword1">empty</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>])?<span class="php-keyword2">strip_tags</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]):<span class="php-quote">''</span>; <span class="php-keyword1">unset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]); <span class="php-keyword1">return</span> <span class="php-var">$space</span>; } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> getController(<span class="php-var">$var</span>,<span class="php-var">$urlCase</span>) { <span class="php-var">$controller</span> = (!<span class="php-keyword1">empty</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>])? <span class="php-var">$_GET</span>[<span class="php-var">$var</span>]:C(<span class="php-quote">'DEFAULT_CONTROLLER'</span>)); <span class="php-keyword1">unset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]); <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_CONTROLLER_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$controller</span>)])) { <span class="php-keyword2">define</span>(<span class="php-quote">'CONTROLLER_ALIAS'</span>,<span class="php-keyword2">strtolower</span>(<span class="php-var">$controller</span>)); <span class="php-keyword1">return</span> <span class="php-keyword2">ucfirst</span>(<span class="php-var">$maps</span>[CONTROLLER_ALIAS]); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$controller</span>),<span class="php-var">$maps</span>)){ <span class="php-keyword1">return</span> <span class="php-quote">''</span>; } } <span class="php-keyword1">if</span>(<span class="php-var">$urlCase</span>) { <span class="php-var">$controller</span> = parse_name(<span class="php-var">$controller</span>,<span class="php-num">1</span>); } <span class="php-keyword1">return</span> <span class="php-keyword2">strip_tags</span>(<span class="php-keyword2">ucfirst</span>(<span class="php-var">$controller</span>)); } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> getAction(<span class="php-var">$var</span>,<span class="php-var">$urlCase</span>) { <span class="php-var">$action</span> = !<span class="php-keyword1">empty</span>(<span class="php-var">$_POST</span>[<span class="php-var">$var</span>]) ? <span class="php-var">$_POST</span>[<span class="php-var">$var</span>] : (!<span class="php-keyword1">empty</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>])?<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]:C(<span class="php-quote">'DEFAULT_ACTION'</span>)); <span class="php-keyword1">unset</span>(<span class="php-var">$_POST</span>[<span class="php-var">$var</span>],<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]); <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_ACTION_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(CONTROLLER_NAME)])) { <span class="php-var">$maps</span> = <span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(CONTROLLER_NAME)]; <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$action</span>)])) { <span class="php-keyword2">define</span>(<span class="php-quote">'ACTION_ALIAS'</span>,<span class="php-keyword2">strtolower</span>(<span class="php-var">$action</span>)); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$maps</span>[ACTION_ALIAS])){ <span class="php-keyword2">parse_str</span>(<span class="php-var">$maps</span>[ACTION_ALIAS][<span class="php-num">1</span>],<span class="php-var">$vars</span>); <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$_GET</span>,<span class="php-var">$vars</span>); <span class="php-keyword1">return</span> <span class="php-var">$maps</span>[ACTION_ALIAS][<span class="php-num">0</span>]; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-var">$maps</span>[ACTION_ALIAS]; } }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$action</span>),<span class="php-var">$maps</span>)){ <span class="php-keyword1">return</span> <span class="php-quote">''</span>; } } } <span class="php-keyword1">return</span> <span class="php-keyword2">strip_tags</span>( <span class="php-var">$urlCase</span>? <span class="php-keyword2">strtolower</span>(<span class="php-var">$action</span>) : <span class="php-var">$action</span> ); } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> getModule(<span class="php-var">$var</span>) { <span class="php-var">$module</span> = (!<span class="php-keyword1">empty</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>])?<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]:C(<span class="php-quote">'DEFAULT_MODULE'</span>)); <span class="php-keyword1">unset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$var</span>]); <span class="php-keyword1">if</span>(<span class="php-var">$maps</span> = C(<span class="php-quote">'URL_MODULE_MAP'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$module</span>)])) { <span class="php-keyword2">define</span>(<span class="php-quote">'MODULE_ALIAS'</span>,<span class="php-keyword2">strtolower</span>(<span class="php-var">$module</span>)); <span class="php-keyword1">return</span> <span class="php-keyword2">ucfirst</span>(<span class="php-var">$maps</span>[MODULE_ALIAS]); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">array_search</span>(<span class="php-keyword2">strtolower</span>(<span class="php-var">$module</span>),<span class="php-var">$maps</span>)){ <span class="php-keyword1">return</span> <span class="php-quote">''</span>; } } <span class="php-keyword1">return</span> <span class="php-keyword2">strip_tags</span>(<span class="php-keyword2">ucfirst</span>(<span class="php-var">$module</span>)); } }}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">class</span> Route { <span class="php-keyword1">public</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> check(){ <span class="php-var">$depr</span> = C(<span class="php-quote">'URL_PATHINFO_DEPR'</span>); <span class="php-var">$regx</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/\.'</span>.__EXT__.<span class="php-quote">'$/i'</span>,<span class="php-quote">''</span>,<span class="php-keyword2">trim</span>(<span class="php-var">$_SERVER</span>[<span class="php-quote">'PATH_INFO'</span>],<span class="php-var">$depr</span>)); <span class="php-keyword1">if</span>(<span class="php-quote">'/'</span> != <span class="php-var">$depr</span>){ <span class="php-var">$regx</span> = <span class="php-keyword2">str_replace</span>(<span class="php-var">$depr</span>,<span class="php-quote">'/'</span>,<span class="php-var">$regx</span>); } <span class="php-var">$maps</span> = C(<span class="php-quote">'URL_MAP_RULES'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$maps</span>[<span class="php-var">$regx</span>])) { <span class="php-var">$var</span> = self::parseUrl(<span class="php-var">$maps</span>[<span class="php-var">$regx</span>]); <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>, <span class="php-var">$_GET</span>); <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-var">$routes</span> = C(<span class="php-quote">'URL_ROUTE_RULES'</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$routes</span>)) { <span class="php-keyword1">foreach</span> (<span class="php-var">$routes</span> <span class="php-keyword1">as</span> <span class="php-var">$rule</span>=&gt;<span class="php-var">$route</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">is_numeric</span>(<span class="php-var">$rule</span>)){ <span class="php-var">$rule</span> = <span class="php-keyword2">array_shift</span>(<span class="php-var">$route</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$route</span>[<span class="php-num">2</span>])){ <span class="php-var">$options</span> = <span class="php-var">$route</span>[<span class="php-num">2</span>]; <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$options</span>[<span class="php-quote">'ext'</span>]) &amp;&amp; __EXT__ != <span class="php-var">$options</span>[<span class="php-quote">'ext'</span>]){ <span class="php-keyword1">continue</span>; } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$options</span>[<span class="php-quote">'method'</span>]) &amp;&amp; REQUEST_METHOD != <span class="php-keyword2">strtoupper</span>(<span class="php-var">$options</span>[<span class="php-quote">'method'</span>])){ <span class="php-keyword1">continue</span>; } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$options</span>[<span class="php-quote">'callback'</span>]) &amp;&amp; <span class="php-keyword2">is_callable</span>(<span class="php-var">$options</span>[<span class="php-quote">'callback'</span>])) { <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">call_user_func</span>(<span class="php-var">$options</span>[<span class="php-quote">'callback'</span>])) { <span class="php-keyword1">continue</span>; } } } <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$rule</span>,<span class="php-quote">'/'</span>) &amp;&amp; <span class="php-keyword2">preg_match</span>(<span class="php-var">$rule</span>,<span class="php-var">$regx</span>,<span class="php-var">$matches</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$route</span> <span class="php-keyword1">instanceof</span> \Closure) { <span class="php-var">$result</span> = self::invokeRegx(<span class="php-var">$route</span>, <span class="php-var">$matches</span>); <span class="php-keyword1">return</span> <span class="php-keyword2">is_bool</span>(<span class="php-var">$result</span>) ? <span class="php-var">$result</span> : <span class="php-keyword1">exit</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> self::parseRegex(<span class="php-var">$matches</span>,<span class="php-var">$route</span>,<span class="php-var">$regx</span>); } }<span class="php-keyword1">else</span>{ <span class="php-var">$len1</span> = <span class="php-keyword2">substr_count</span>(<span class="php-var">$regx</span>,<span class="php-quote">'/'</span>); <span class="php-var">$len2</span> = <span class="php-keyword2">substr_count</span>(<span class="php-var">$rule</span>,<span class="php-quote">'/'</span>); <span class="php-keyword1">if</span>(<span class="php-var">$len1</span>&gt;=<span class="php-var">$len2</span> || <span class="php-keyword2">strpos</span>(<span class="php-var">$rule</span>,<span class="php-quote">'['</span>)) { <span class="php-keyword1">if</span>(<span class="php-quote">'$'</span> == <span class="php-keyword2">substr</span>(<span class="php-var">$rule</span>,-<span class="php-num">1</span>,<span class="php-num">1</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$len1</span> != <span class="php-var">$len2</span>) { <span class="php-keyword1">continue</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$rule</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$rule</span>,<span class="php-num">0</span>,-<span class="php-num">1</span>); } } <span class="php-var">$match</span> = self::checkUrlMatch(<span class="php-var">$regx</span>,<span class="php-var">$rule</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-var">$match</span>) { <span class="php-keyword1">if</span>(<span class="php-var">$route</span> <span class="php-keyword1">instanceof</span> \Closure) { <span class="php-var">$result</span> = self::invokeRule(<span class="php-var">$route</span>, <span class="php-var">$match</span>); <span class="php-keyword1">return</span> <span class="php-keyword2">is_bool</span>(<span class="php-var">$result</span>) ? <span class="php-var">$result</span> : <span class="php-keyword1">exit</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> self::parseRule(<span class="php-var">$rule</span>,<span class="php-var">$route</span>,<span class="php-var">$regx</span>); } } } } } } <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> checkUrlMatch(<span class="php-var">$regx</span>,<span class="php-var">$rule</span>) { <span class="php-var">$m1</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$regx</span>); <span class="php-var">$m2</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$rule</span>); <span class="php-var">$var</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">foreach</span> (<span class="php-var">$m2</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span>=&gt;<span class="php-var">$val</span>){ <span class="php-keyword1">if</span>(<span class="php-num">0</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">'[:'</span>)){ <span class="php-var">$val</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>,<span class="php-num">1</span>,-<span class="php-num">1</span>); } <span class="php-keyword1">if</span>(<span class="php-quote">':'</span> == <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>,<span class="php-num">0</span>,<span class="php-num">1</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$pos</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">'|'</span>)){ <span class="php-var">$val</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>,<span class="php-num">1</span>,<span class="php-var">$pos</span>-<span class="php-num">1</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">'\\'</span>)) { <span class="php-var">$type</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>,-<span class="php-num">1</span>); <span class="php-keyword1">if</span>(<span class="php-quote">'d'</span>==<span class="php-var">$type</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$m1</span>[<span class="php-var">$key</span>]) &amp;&amp; !<span class="php-keyword2">is_numeric</span>(<span class="php-var">$m1</span>[<span class="php-var">$key</span>])) <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-var">$name</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>, <span class="php-num">1</span>, -<span class="php-num">2</span>); }<span class="php-keyword1">elseif</span>(<span class="php-var">$pos</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">'^'</span>)){ <span class="php-var">$array</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'-'</span>,<span class="php-keyword2">substr</span>(<span class="php-keyword2">strstr</span>(<span class="php-var">$val</span>,<span class="php-quote">'^'</span>),<span class="php-num">1</span>)); <span class="php-keyword1">if</span>(<span class="php-keyword2">in_array</span>(<span class="php-var">$m1</span>[<span class="php-var">$key</span>],<span class="php-var">$array</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-var">$name</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>, <span class="php-num">1</span>, <span class="php-var">$pos</span> - <span class="php-num">1</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$name</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$val</span>, <span class="php-num">1</span>); } <span class="php-var">$var</span>[<span class="php-var">$name</span>] = <span class="php-keyword1">isset</span>(<span class="php-var">$m1</span>[<span class="php-var">$key</span>])?<span class="php-var">$m1</span>[<span class="php-var">$key</span>]:<span class="php-quote">''</span>; }<span class="php-keyword1">elseif</span>(<span class="php-num">0</span> !== <span class="php-keyword2">strcasecmp</span>(<span class="php-var">$val</span>,<span class="php-var">$m1</span>[<span class="php-var">$key</span>])){ <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } <span class="php-keyword1">return</span> <span class="php-var">$var</span>; } <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> parseUrl(<span class="php-var">$url</span>) { <span class="php-var">$var</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">if</span>(<span class="php-keyword1">false</span> !== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'?'</span>)) { <span class="php-var">$info</span> = <span class="php-keyword2">parse_url</span>(<span class="php-var">$url</span>); <span class="php-var">$path</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$info</span>[<span class="php-quote">'path'</span>]); <span class="php-keyword2">parse_str</span>(<span class="php-var">$info</span>[<span class="php-quote">'query'</span>],<span class="php-var">$var</span>); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'/'</span>)){ <span class="php-var">$path</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$url</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword2">parse_str</span>(<span class="php-var">$url</span>,<span class="php-var">$var</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$path</span>)) { <span class="php-var">$var</span>[C(<span class="php-quote">'VAR_ACTION'</span>)] = <span class="php-keyword2">array_pop</span>(<span class="php-var">$path</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$path</span>)) { <span class="php-var">$var</span>[C(<span class="php-quote">'VAR_CONTROLLER'</span>)] = <span class="php-keyword2">array_pop</span>(<span class="php-var">$path</span>); } <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$path</span>)) { <span class="php-var">$var</span>[C(<span class="php-quote">'VAR_MODULE'</span>)] = <span class="php-keyword2">array_pop</span>(<span class="php-var">$path</span>); } } <span class="php-keyword1">return</span> <span class="php-var">$var</span>; } <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> parseRule(<span class="php-var">$rule</span>,<span class="php-var">$route</span>,<span class="php-var">$regx</span>) { <span class="php-var">$url</span> = <span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>)?<span class="php-var">$route</span>[<span class="php-num">0</span>]:<span class="php-var">$route</span>; <span class="php-var">$paths</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$regx</span>); <span class="php-var">$matches</span> = <span class="php-keyword1">array</span>(); <span class="php-var">$rule</span> = <span class="php-keyword2">explode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$rule</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$rule</span> <span class="php-keyword1">as</span> <span class="php-var">$item</span>){ <span class="php-var">$fun</span> = <span class="php-quote">''</span>; <span class="php-keyword1">if</span>(<span class="php-num">0</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$item</span>,<span class="php-quote">'[:'</span>)){ <span class="php-var">$item</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-num">1</span>,-<span class="php-num">1</span>); } <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$item</span>,<span class="php-quote">':'</span>)) { <span class="php-keyword1">if</span>(<span class="php-var">$pos</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$item</span>,<span class="php-quote">'|'</span>)){ <span class="php-var">$fun</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-var">$pos</span>+<span class="php-num">1</span>); <span class="php-var">$item</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-num">0</span>,<span class="php-var">$pos</span>); } <span class="php-keyword1">if</span>(<span class="php-var">$pos</span> = <span class="php-keyword2">strpos</span>(<span class="php-var">$item</span>,<span class="php-quote">'^'</span>) ) { <span class="php-var">$var</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-num">1</span>,<span class="php-var">$pos</span>-<span class="php-num">1</span>); }<span class="php-keyword1">elseif</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$item</span>,<span class="php-quote">'\\'</span>)){ <span class="php-var">$var</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-num">1</span>,-<span class="php-num">2</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$var</span> = <span class="php-keyword2">substr</span>(<span class="php-var">$item</span>,<span class="php-num">1</span>); } <span class="php-var">$matches</span>[<span class="php-var">$var</span>] = !<span class="php-keyword1">empty</span>(<span class="php-var">$fun</span>)? <span class="php-var">$fun</span>(<span class="php-keyword2">array_shift</span>(<span class="php-var">$paths</span>)) : <span class="php-keyword2">array_shift</span>(<span class="php-var">$paths</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword2">array_shift</span>(<span class="php-var">$paths</span>); } } <span class="php-keyword1">if</span>(<span class="php-num">0</span>=== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'/'</span>) || <span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'http'</span>)) { <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">':'</span>)) { <span class="php-var">$values</span> = <span class="php-keyword2">array_values</span>(<span class="php-var">$matches</span>); <span class="php-var">$url</span> = <span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/:(\d+)/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>) <span class="php-keyword1">use</span>(<span class="php-var">$values</span>){ <span class="php-keyword1">return</span> <span class="php-var">$values</span>[<span class="php-var">$match</span>[<span class="php-num">1</span>] - <span class="php-num">1</span>]; }, <span class="php-var">$url</span>); } <span class="php-keyword2">header</span>(<span class="php-quote">&quot;Location: </span><span class="php-var">$url</span><span class="php-quote">&quot;</span>, <span class="php-keyword1">true</span>,(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>]))?<span class="php-var">$route</span>[<span class="php-num">1</span>]:<span class="php-num">301</span>); <span class="php-keyword1">exit</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$var</span> = self::parseUrl(<span class="php-var">$url</span>); <span class="php-var">$values</span> = <span class="php-keyword2">array_values</span>(<span class="php-var">$matches</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$var</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span>=&gt;<span class="php-var">$val</span>){ <span class="php-keyword1">if</span>(<span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">':'</span>)) { <span class="php-var">$var</span>[<span class="php-var">$key</span>] = <span class="php-var">$values</span>[<span class="php-keyword2">substr</span>(<span class="php-var">$val</span>,<span class="php-num">1</span>)-<span class="php-num">1</span>]; } } <span class="php-var">$var</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$matches</span>,<span class="php-var">$var</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$paths</span>)) { <span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/(\w+)\/([^\/]+)/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>) <span class="php-keyword1">use</span>(&amp;<span class="php-var">$var</span>){ <span class="php-var">$var</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$match</span>[<span class="php-num">1</span>])]=<span class="php-keyword2">strip_tags</span>(<span class="php-var">$match</span>[<span class="php-num">2</span>]);}, <span class="php-keyword2">implode</span>(<span class="php-quote">'/'</span>,<span class="php-var">$paths</span>)); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>])) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>])){ <span class="php-var">$params</span> = <span class="php-var">$route</span>[<span class="php-num">1</span>]; }<span class="php-keyword1">else</span>{ <span class="php-keyword2">parse_str</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>],<span class="php-var">$params</span>); } <span class="php-var">$var</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>,<span class="php-var">$params</span>); } <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>,<span class="php-var">$_GET</span>); } <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> parseRegex(<span class="php-var">$matches</span>,<span class="php-var">$route</span>,<span class="php-var">$regx</span>) { <span class="php-var">$url</span> = <span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>)?<span class="php-var">$route</span>[<span class="php-num">0</span>]:<span class="php-var">$route</span>; <span class="php-var">$url</span> = <span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/:(\d+)/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>) <span class="php-keyword1">use</span>(<span class="php-var">$matches</span>){<span class="php-keyword1">return</span> <span class="php-var">$matches</span>[<span class="php-var">$match</span>[<span class="php-num">1</span>]];}, <span class="php-var">$url</span>); <span class="php-keyword1">if</span>(<span class="php-num">0</span>=== <span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'/'</span>) || <span class="php-num">0</span>===<span class="php-keyword2">strpos</span>(<span class="php-var">$url</span>,<span class="php-quote">'http'</span>)) { <span class="php-keyword2">header</span>(<span class="php-quote">&quot;Location: </span><span class="php-var">$url</span><span class="php-quote">&quot;</span>, <span class="php-keyword1">true</span>,(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>]))?<span class="php-var">$route</span>[<span class="php-num">1</span>]:<span class="php-num">301</span>); <span class="php-keyword1">exit</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$var</span> = self::parseUrl(<span class="php-var">$url</span>); <span class="php-keyword1">foreach</span>(<span class="php-var">$var</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span>=&gt;<span class="php-var">$val</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$val</span>,<span class="php-quote">'|'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$val</span>,<span class="php-var">$fun</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'|'</span>,<span class="php-var">$val</span>); <span class="php-var">$var</span>[<span class="php-var">$key</span>] = <span class="php-var">$fun</span>(<span class="php-var">$val</span>); } } <span class="php-var">$regx</span> = <span class="php-keyword2">substr_replace</span>(<span class="php-var">$regx</span>,<span class="php-quote">''</span>,<span class="php-num">0</span>,<span class="php-keyword2">strlen</span>(<span class="php-var">$matches</span>[<span class="php-num">0</span>])); <span class="php-keyword1">if</span>(<span class="php-var">$regx</span>) { <span class="php-keyword2">preg_replace_callback</span>(<span class="php-quote">'/(\w+)\/([^\/]+)/'</span>, <span class="php-keyword1">function</span>(<span class="php-var">$match</span>) <span class="php-keyword1">use</span>(&amp;<span class="php-var">$var</span>){ <span class="php-var">$var</span>[<span class="php-keyword2">strtolower</span>(<span class="php-var">$match</span>[<span class="php-num">1</span>])] = <span class="php-keyword2">strip_tags</span>(<span class="php-var">$match</span>[<span class="php-num">2</span>]); }, <span class="php-var">$regx</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>) &amp;&amp; <span class="php-keyword1">isset</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>])) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>])){ <span class="php-var">$params</span> = <span class="php-var">$route</span>[<span class="php-num">1</span>]; }<span class="php-keyword1">else</span>{ <span class="php-keyword2">parse_str</span>(<span class="php-var">$route</span>[<span class="php-num">1</span>],<span class="php-var">$params</span>); } <span class="php-var">$var</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>,<span class="php-var">$params</span>); } <span class="php-var">$_GET</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$var</span>,<span class="php-var">$_GET</span>); } <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> invokeRegx(<span class="php-var">$closure</span>, <span class="php-var">$var</span> = <span class="php-keyword1">array</span>()) { <span class="php-var">$reflect</span> = <span class="php-keyword1">new</span> \ReflectionFunction(<span class="php-var">$closure</span>); <span class="php-var">$params</span> = <span class="php-var">$reflect</span>-&gt;getParameters(); <span class="php-var">$args</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword2">array_shift</span>(<span class="php-var">$var</span>); <span class="php-keyword1">foreach</span> (<span class="php-var">$params</span> <span class="php-keyword1">as</span> <span class="php-var">$param</span>){ <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$var</span>)) { <span class="php-var">$args</span>[] = <span class="php-keyword2">array_shift</span>(<span class="php-var">$var</span>); }<span class="php-keyword1">elseif</span>(<span class="php-var">$param</span>-&gt;isDefaultValueAvailable()){ <span class="php-var">$args</span>[] = <span class="php-var">$param</span>-&gt;getDefaultValue(); } } <span class="php-keyword1">return</span> <span class="php-var">$reflect</span>-&gt;invokeArgs(<span class="php-var">$args</span>); } <span class="php-keyword1">static</span> <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> invokeRule(<span class="php-var">$closure</span>, <span class="php-var">$var</span> = <span class="php-keyword1">array</span>()) { <span class="php-var">$reflect</span> = <span class="php-keyword1">new</span> \ReflectionFunction(<span class="php-var">$closure</span>); <span class="php-var">$params</span> = <span class="php-var">$reflect</span>-&gt;getParameters(); <span class="php-var">$args</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">foreach</span> (<span class="php-var">$params</span> <span class="php-keyword1">as</span> <span class="php-var">$param</span>){ <span class="php-var">$name</span> = <span class="php-var">$param</span>-&gt;getName(); <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$var</span>[<span class="php-var">$name</span>])) { <span class="php-var">$args</span>[] = <span class="php-var">$var</span>[<span class="php-var">$name</span>]; }<span class="php-keyword1">elseif</span>(<span class="php-var">$param</span>-&gt;isDefaultValueAvailable()){ <span class="php-var">$args</span>[] = <span class="php-var">$param</span>-&gt;getDefaultValue(); } } <span class="php-keyword1">return</span> <span class="php-var">$reflect</span>-&gt;invokeArgs(<span class="php-var">$args</span>); } }}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">abstract</span> <span class="php-keyword1">class</span> Controller { <span class="php-keyword1">protected</span> <span class="php-var">$view</span> = <span class="php-keyword1">null</span>; <span class="php-keyword1">protected</span> <span class="php-var">$config</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __construct() { Hook::listen(<span class="php-quote">'action_begin'</span>,<span class="php-var">$this</span>-&gt;config); <span class="php-var">$this</span>-&gt;view = Think::instance(<span class="php-quote">'Think\View'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">method_exists</span>(<span class="php-var">$this</span>,<span class="php-quote">'_initialize'</span>)) <span class="php-var">$this</span>-&gt;_initialize(); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> display(<span class="php-var">$templateFile</span>=<span class="php-quote">''</span>,<span class="php-var">$charset</span>=<span class="php-quote">''</span>,<span class="php-var">$contentType</span>=<span class="php-quote">''</span>,<span class="php-var">$content</span>=<span class="php-quote">''</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-var">$this</span>-&gt;view-&gt;display(<span class="php-var">$templateFile</span>,<span class="php-var">$charset</span>,<span class="php-var">$contentType</span>,<span class="php-var">$content</span>,<span class="php-var">$prefix</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> show(<span class="php-var">$content</span>,<span class="php-var">$charset</span>=<span class="php-quote">''</span>,<span class="php-var">$contentType</span>=<span class="php-quote">''</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-var">$this</span>-&gt;view-&gt;display(<span class="php-quote">''</span>,<span class="php-var">$charset</span>,<span class="php-var">$contentType</span>,<span class="php-var">$content</span>,<span class="php-var">$prefix</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> fetch(<span class="php-var">$templateFile</span>=<span class="php-quote">''</span>,<span class="php-var">$content</span>=<span class="php-quote">''</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">return</span> <span class="php-var">$this</span>-&gt;view-&gt;fetch(<span class="php-var">$templateFile</span>,<span class="php-var">$content</span>,<span class="php-var">$prefix</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> buildHtml(<span class="php-var">$htmlfile</span>=<span class="php-quote">''</span>,<span class="php-var">$htmlpath</span>=<span class="php-quote">''</span>,<span class="php-var">$templateFile</span>=<span class="php-quote">''</span>) { <span class="php-var">$content</span> = <span class="php-var">$this</span>-&gt;fetch(<span class="php-var">$templateFile</span>); <span class="php-var">$htmlpath</span> = !<span class="php-keyword1">empty</span>(<span class="php-var">$htmlpath</span>)?<span class="php-var">$htmlpath</span>:HTML_PATH; <span class="php-var">$htmlfile</span> = <span class="php-var">$htmlpath</span>.<span class="php-var">$htmlfile</span>.C(<span class="php-quote">'HTML_FILE_SUFFIX'</span>); Storage::put(<span class="php-var">$htmlfile</span>,<span class="php-var">$content</span>,<span class="php-quote">'html'</span>); <span class="php-keyword1">return</span> <span class="php-var">$content</span>; } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> theme(<span class="php-var">$theme</span>){ <span class="php-var">$this</span>-&gt;view-&gt;theme(<span class="php-var">$theme</span>); <span class="php-keyword1">return</span> <span class="php-var">$this</span>; } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> assign(<span class="php-var">$name</span>,<span class="php-var">$value</span>=<span class="php-quote">''</span>) { <span class="php-var">$this</span>-&gt;view-&gt;assign(<span class="php-var">$name</span>,<span class="php-var">$value</span>); <span class="php-keyword1">return</span> <span class="php-var">$this</span>; } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __set(<span class="php-var">$name</span>,<span class="php-var">$value</span>) { <span class="php-var">$this</span>-&gt;assign(<span class="php-var">$name</span>,<span class="php-var">$value</span>); } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> get(<span class="php-var">$name</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">return</span> <span class="php-var">$this</span>-&gt;view-&gt;get(<span class="php-var">$name</span>); } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __get(<span class="php-var">$name</span>) { <span class="php-keyword1">return</span> <span class="php-var">$this</span>-&gt;get(<span class="php-var">$name</span>); } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __isset(<span class="php-var">$name</span>) { <span class="php-keyword1">return</span> <span class="php-var">$this</span>-&gt;get(<span class="php-var">$name</span>); } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __call(<span class="php-var">$method</span>,<span class="php-var">$args</span>) { <span class="php-keyword1">if</span>( <span class="php-num">0</span> === <span class="php-keyword2">strcasecmp</span>(<span class="php-var">$method</span>,ACTION_NAME.C(<span class="php-quote">'ACTION_SUFFIX'</span>))) { <span class="php-keyword1">if</span>(<span class="php-keyword2">method_exists</span>(<span class="php-var">$this</span>,<span class="php-quote">'_empty'</span>)) { <span class="php-var">$this</span>-&gt;_empty(<span class="php-var">$method</span>,<span class="php-var">$args</span>); }<span class="php-keyword1">elseif</span>(file_exists_case(<span class="php-var">$this</span>-&gt;view-&gt;parseTemplate())){ <span class="php-var">$this</span>-&gt;display(); }<span class="php-keyword1">else</span>{ E(L(<span class="php-quote">'_ERROR_ACTION_'</span>).<span class="php-quote">':'</span>.ACTION_NAME); } }<span class="php-keyword1">else</span>{ E(__CLASS__.<span class="php-quote">':'</span>.<span class="php-var">$method</span>.L(<span class="php-quote">'_METHOD_NOT_EXIST_'</span>)); <span class="php-keyword1">return</span>; } } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> error(<span class="php-var">$message</span>=<span class="php-quote">''</span>,<span class="php-var">$jumpUrl</span>=<span class="php-quote">''</span>,<span class="php-var">$ajax</span>=<span class="php-keyword1">false</span>) { <span class="php-var">$this</span>-&gt;dispatchJump(<span class="php-var">$message</span>,<span class="php-num">0</span>,<span class="php-var">$jumpUrl</span>,<span class="php-var">$ajax</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> success(<span class="php-var">$message</span>=<span class="php-quote">''</span>,<span class="php-var">$jumpUrl</span>=<span class="php-quote">''</span>,<span class="php-var">$ajax</span>=<span class="php-keyword1">false</span>) { <span class="php-var">$this</span>-&gt;dispatchJump(<span class="php-var">$message</span>,<span class="php-num">1</span>,<span class="php-var">$jumpUrl</span>,<span class="php-var">$ajax</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> ajaxReturn(<span class="php-var">$data</span>,<span class="php-var">$type</span>=<span class="php-quote">''</span>,<span class="php-var">$json_option</span>=<span class="php-num">0</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$type</span>)) <span class="php-var">$type</span> = C(<span class="php-quote">'DEFAULT_AJAX_RETURN'</span>); <span class="php-keyword1">switch</span> (<span class="php-keyword2">strtoupper</span>(<span class="php-var">$type</span>)){ <span class="php-keyword1">case</span> <span class="php-quote">'JSON'</span> : <span class="php-keyword2">header</span>(<span class="php-quote">'Content-Type:application/json; charset=utf-8'</span>); <span class="php-keyword1">exit</span>(<span class="php-keyword2">json_encode</span>(<span class="php-var">$data</span>,<span class="php-var">$json_option</span>)); <span class="php-keyword1">case</span> <span class="php-quote">'XML'</span> : <span class="php-keyword2">header</span>(<span class="php-quote">'Content-Type:text/xml; charset=utf-8'</span>); <span class="php-keyword1">exit</span>(xml_encode(<span class="php-var">$data</span>)); <span class="php-keyword1">case</span> <span class="php-quote">'JSONP'</span>: <span class="php-keyword2">header</span>(<span class="php-quote">'Content-Type:application/json; charset=utf-8'</span>); <span class="php-var">$handler</span> = <span class="php-keyword1">isset</span>(<span class="php-var">$_GET</span>[C(<span class="php-quote">'VAR_JSONP_HANDLER'</span>)]) ? <span class="php-var">$_GET</span>[C(<span class="php-quote">'VAR_JSONP_HANDLER'</span>)] : C(<span class="php-quote">'DEFAULT_JSONP_HANDLER'</span>); <span class="php-keyword1">exit</span>(<span class="php-var">$handler</span>.<span class="php-quote">'('</span>.<span class="php-keyword2">json_encode</span>(<span class="php-var">$data</span>,<span class="php-var">$json_option</span>).<span class="php-quote">');'</span>); <span class="php-keyword1">case</span> <span class="php-quote">'EVAL'</span> : <span class="php-keyword2">header</span>(<span class="php-quote">'Content-Type:text/html; charset=utf-8'</span>); <span class="php-keyword1">exit</span>(<span class="php-var">$data</span>); <span class="php-keyword1">default</span> : Hook::listen(<span class="php-quote">'ajax_return'</span>,<span class="php-var">$data</span>); } } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> redirect(<span class="php-var">$url</span>,<span class="php-var">$params</span>=<span class="php-keyword1">array</span>(),<span class="php-var">$delay</span>=<span class="php-num">0</span>,<span class="php-var">$msg</span>=<span class="php-quote">''</span>) { <span class="php-var">$url</span> = U(<span class="php-var">$url</span>,<span class="php-var">$params</span>); redirect(<span class="php-var">$url</span>,<span class="php-var">$delay</span>,<span class="php-var">$msg</span>); } <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> dispatchJump(<span class="php-var">$message</span>,<span class="php-var">$status</span>=<span class="php-num">1</span>,<span class="php-var">$jumpUrl</span>=<span class="php-quote">''</span>,<span class="php-var">$ajax</span>=<span class="php-keyword1">false</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">true</span> === <span class="php-var">$ajax</span> || IS_AJAX) { <span class="php-var">$data</span> = <span class="php-keyword2">is_array</span>(<span class="php-var">$ajax</span>)?<span class="php-var">$ajax</span>:<span class="php-keyword1">array</span>(); <span class="php-var">$data</span>[<span class="php-quote">'info'</span>] = <span class="php-var">$message</span>; <span class="php-var">$data</span>[<span class="php-quote">'status'</span>] = <span class="php-var">$status</span>; <span class="php-var">$data</span>[<span class="php-quote">'url'</span>] = <span class="php-var">$jumpUrl</span>; <span class="php-var">$this</span>-&gt;ajaxReturn(<span class="php-var">$data</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">is_int</span>(<span class="php-var">$ajax</span>)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'waitSecond'</span>,<span class="php-var">$ajax</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$jumpUrl</span>)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'jumpUrl'</span>,<span class="php-var">$jumpUrl</span>); <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'msgTitle'</span>,<span class="php-var">$status</span>? L(<span class="php-quote">'_OPERATION_SUCCESS_'</span>) : L(<span class="php-quote">'_OPERATION_FAIL_'</span>)); <span class="php-keyword1">if</span>(<span class="php-var">$this</span>-&gt;get(<span class="php-quote">'closeWin'</span>)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'jumpUrl'</span>,<span class="php-quote">'javascript:window.close();'</span>); <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'status'</span>,<span class="php-var">$status</span>); C(<span class="php-quote">'HTML_CACHE_ON'</span>,<span class="php-keyword1">false</span>); <span class="php-keyword1">if</span>(<span class="php-var">$status</span>) { <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'message'</span>,<span class="php-var">$message</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$this</span>-&gt;waitSecond)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'waitSecond'</span>,<span class="php-quote">'1'</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$this</span>-&gt;jumpUrl)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">&quot;jumpUrl&quot;</span>,<span class="php-var">$_SERVER</span>[<span class="php-quote">&quot;HTTP_REFERER&quot;</span>]); <span class="php-var">$this</span>-&gt;display(C(<span class="php-quote">'TMPL_ACTION_SUCCESS'</span>)); }<span class="php-keyword1">else</span>{ <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'error'</span>,<span class="php-var">$message</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$this</span>-&gt;waitSecond)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'waitSecond'</span>,<span class="php-quote">'3'</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword1">isset</span>(<span class="php-var">$this</span>-&gt;jumpUrl)) <span class="php-var">$this</span>-&gt;assign(<span class="php-quote">'jumpUrl'</span>,<span class="php-quote">&quot;javascript:history.back(-1);&quot;</span>); <span class="php-var">$this</span>-&gt;display(C(<span class="php-quote">'TMPL_ACTION_ERROR'</span>)); <span class="php-keyword1">exit</span> ; } } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> __destruct() { Hook::listen(<span class="php-quote">'action_end'</span>); } } <span class="php-keyword2">class_alias</span>(<span class="php-quote">'Think\Controller'</span>,<span class="php-quote">'Think\Action'</span>);}<span class="php-keyword1">namespace</span> Think{ <span class="php-keyword1">class</span> View { <span class="php-keyword1">protected</span> <span class="php-var">$tVar</span> = <span class="php-keyword1">array</span>(); <span class="php-keyword1">protected</span> <span class="php-var">$theme</span> = <span class="php-quote">''</span>; <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> assign(<span class="php-var">$name</span>,<span class="php-var">$value</span>=<span class="php-quote">''</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(<span class="php-var">$name</span>)) { <span class="php-var">$this</span>-&gt;tVar = <span class="php-keyword2">array_merge</span>(<span class="php-var">$this</span>-&gt;tVar,<span class="php-var">$name</span>); }<span class="php-keyword1">else</span> { <span class="php-var">$this</span>-&gt;tVar[<span class="php-var">$name</span>] = <span class="php-var">$value</span>; } } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> get(<span class="php-var">$name</span>=<span class="php-quote">''</span>){ <span class="php-keyword1">if</span>(<span class="php-quote">''</span> === <span class="php-var">$name</span>) { <span class="php-keyword1">return</span> <span class="php-var">$this</span>-&gt;tVar; } <span class="php-keyword1">return</span> <span class="php-keyword1">isset</span>(<span class="php-var">$this</span>-&gt;tVar[<span class="php-var">$name</span>])?<span class="php-var">$this</span>-&gt;tVar[<span class="php-var">$name</span>]:<span class="php-keyword1">false</span>; } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> display(<span class="php-var">$templateFile</span>=<span class="php-quote">''</span>,<span class="php-var">$charset</span>=<span class="php-quote">''</span>,<span class="php-var">$contentType</span>=<span class="php-quote">''</span>,<span class="php-var">$content</span>=<span class="php-quote">''</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { G(<span class="php-quote">'viewStartTime'</span>); Hook::listen(<span class="php-quote">'view_begin'</span>,<span class="php-var">$templateFile</span>); <span class="php-var">$content</span> = <span class="php-var">$this</span>-&gt;fetch(<span class="php-var">$templateFile</span>,<span class="php-var">$content</span>,<span class="php-var">$prefix</span>); <span class="php-var">$this</span>-&gt;render(<span class="php-var">$content</span>,<span class="php-var">$charset</span>,<span class="php-var">$contentType</span>); Hook::listen(<span class="php-quote">'view_end'</span>); } <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> render(<span class="php-var">$content</span>,<span class="php-var">$charset</span>=<span class="php-quote">''</span>,<span class="php-var">$contentType</span>=<span class="php-quote">''</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$charset</span>)) <span class="php-var">$charset</span> = C(<span class="php-quote">'DEFAULT_CHARSET'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$contentType</span>)) <span class="php-var">$contentType</span> = C(<span class="php-quote">'TMPL_CONTENT_TYPE'</span>); <span class="php-keyword2">header</span>(<span class="php-quote">'Content-Type:'</span>.<span class="php-var">$contentType</span>.<span class="php-quote">'; charset='</span>.<span class="php-var">$charset</span>); <span class="php-keyword2">header</span>(<span class="php-quote">'Cache-control: '</span>.C(<span class="php-quote">'HTTP_CACHE_CONTROL'</span>)); <span class="php-keyword2">header</span>(<span class="php-quote">'X-Powered-By:ThinkPHP'</span>); <span class="php-keyword1">echo</span> <span class="php-var">$content</span>; } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> fetch(<span class="php-var">$templateFile</span>=<span class="php-quote">''</span>,<span class="php-var">$content</span>=<span class="php-quote">''</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword1">empty</span>(<span class="php-var">$content</span>)) { <span class="php-var">$templateFile</span> = <span class="php-var">$this</span>-&gt;parseTemplate(<span class="php-var">$templateFile</span>); <span class="php-keyword1">if</span>(!<span class="php-keyword2">is_file</span>(<span class="php-var">$templateFile</span>)) E(L(<span class="php-quote">'_TEMPLATE_NOT_EXIST_'</span>).<span class="php-quote">':'</span>.<span class="php-var">$templateFile</span>); }<span class="php-keyword1">else</span>{ <span class="php-keyword2">defined</span>(<span class="php-quote">'THEME_PATH'</span>) <span class="php-keyword1">or</span> <span class="php-keyword2">define</span>(<span class="php-quote">'THEME_PATH'</span>, <span class="php-var">$this</span>-&gt;getThemePath()); } <span class="php-keyword2">ob_start</span>(); <span class="php-keyword2">ob_implicit_flush</span>(<span class="php-num">0</span>); <span class="php-keyword1">if</span>(<span class="php-quote">'php'</span> == <span class="php-keyword2">strtolower</span>(C(<span class="php-quote">'TMPL_ENGINE_TYPE'</span>))) { <span class="php-var">$_content</span> = <span class="php-var">$content</span>; <span class="php-keyword2">extract</span>(<span class="php-var">$this</span>-&gt;tVar, EXTR_OVERWRITE); <span class="php-keyword1">empty</span>(<span class="php-var">$_content</span>)?<span class="php-keyword1">include</span> <span class="php-var">$templateFile</span>:<span class="php-keyword2">eval</span>(<span class="php-quote">'?&gt;'</span>.<span class="php-var">$_content</span>); }<span class="php-keyword1">else</span>{ <span class="php-var">$params</span> = <span class="php-keyword1">array</span>(<span class="php-quote">'var'</span>=&gt;<span class="php-var">$this</span>-&gt;tVar,<span class="php-quote">'file'</span>=&gt;<span class="php-var">$templateFile</span>,<span class="php-quote">'content'</span>=&gt;<span class="php-var">$content</span>,<span class="php-quote">'prefix'</span>=&gt;<span class="php-var">$prefix</span>); Hook::listen(<span class="php-quote">'view_parse'</span>,<span class="php-var">$params</span>); } <span class="php-var">$content</span> = <span class="php-keyword2">ob_get_clean</span>(); Hook::listen(<span class="php-quote">'view_filter'</span>,<span class="php-var">$content</span>); <span class="php-keyword1">return</span> <span class="php-var">$content</span>; } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> parseTemplate(<span class="php-var">$template</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(<span class="php-var">$template</span>)) { <span class="php-keyword1">return</span> <span class="php-var">$template</span>; } <span class="php-var">$depr</span> = C(<span class="php-quote">'TMPL_FILE_DEPR'</span>); <span class="php-var">$template</span> = <span class="php-keyword2">str_replace</span>(<span class="php-quote">':'</span>, <span class="php-var">$depr</span>, <span class="php-var">$template</span>); <span class="php-var">$module</span> = MODULE_NAME; <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$template</span>,<span class="php-quote">'@'</span>)){ <span class="php-keyword1">list</span>(<span class="php-var">$module</span>,<span class="php-var">$template</span>) = <span class="php-keyword2">explode</span>(<span class="php-quote">'@'</span>,<span class="php-var">$template</span>); } <span class="php-keyword2">defined</span>(<span class="php-quote">'THEME_PATH'</span>) <span class="php-keyword1">or</span> <span class="php-keyword2">define</span>(<span class="php-quote">'THEME_PATH'</span>, <span class="php-var">$this</span>-&gt;getThemePath(<span class="php-var">$module</span>)); <span class="php-keyword1">if</span>(<span class="php-quote">''</span> == <span class="php-var">$template</span>) { <span class="php-var">$template</span> = CONTROLLER_NAME . <span class="php-var">$depr</span> . ACTION_NAME; }<span class="php-keyword1">elseif</span>(<span class="php-keyword1">false</span> === <span class="php-keyword2">strpos</span>(<span class="php-var">$template</span>, <span class="php-var">$depr</span>)){ <span class="php-var">$template</span> = CONTROLLER_NAME . <span class="php-var">$depr</span> . <span class="php-var">$template</span>; } <span class="php-var">$file</span> = THEME_PATH.<span class="php-var">$template</span>.C(<span class="php-quote">'TMPL_TEMPLATE_SUFFIX'</span>); <span class="php-keyword1">if</span>(C(<span class="php-quote">'TMPL_LOAD_DEFAULTTHEME'</span>) &amp;&amp; THEME_NAME != C(<span class="php-quote">'DEFAULT_THEME'</span>) &amp;&amp; !<span class="php-keyword2">is_file</span>(<span class="php-var">$file</span>)){ <span class="php-var">$file</span> = <span class="php-keyword2">dirname</span>(THEME_PATH).<span class="php-quote">'/'</span>.C(<span class="php-quote">'DEFAULT_THEME'</span>).<span class="php-quote">'/'</span>.<span class="php-var">$template</span>.C(<span class="php-quote">'TMPL_TEMPLATE_SUFFIX'</span>); } <span class="php-keyword1">return</span> <span class="php-var">$file</span>; } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> getThemePath(<span class="php-var">$module</span>=MODULE_NAME){ <span class="php-var">$theme</span> = <span class="php-var">$this</span>-&gt;getTemplateTheme(); <span class="php-var">$tmplPath</span> = C(<span class="php-quote">'VIEW_PATH'</span>); <span class="php-keyword1">if</span>(!<span class="php-var">$tmplPath</span>){ <span class="php-var">$tmplPath</span> = <span class="php-keyword2">defined</span>(<span class="php-quote">'TMPL_PATH'</span>)? TMPL_PATH.<span class="php-var">$module</span>.<span class="php-quote">'/'</span> : APP_PATH.<span class="php-var">$module</span>.<span class="php-quote">'/'</span>.C(<span class="php-quote">'DEFAULT_V_LAYER'</span>).<span class="php-quote">'/'</span>; } <span class="php-keyword1">return</span> <span class="php-var">$tmplPath</span>.<span class="php-var">$theme</span>; } <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> theme(<span class="php-var">$theme</span>){ <span class="php-var">$this</span>-&gt;theme = <span class="php-var">$theme</span>; <span class="php-keyword1">return</span> <span class="php-var">$this</span>; } <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> getTemplateTheme() { <span class="php-keyword1">if</span>(<span class="php-var">$this</span>-&gt;theme) { <span class="php-var">$theme</span> = <span class="php-var">$this</span>-&gt;theme; }<span class="php-keyword1">else</span>{ <span class="php-var">$theme</span> = C(<span class="php-quote">'DEFAULT_THEME'</span>); <span class="php-keyword1">if</span>(C(<span class="php-quote">'TMPL_DETECT_THEME'</span>)) { <span class="php-var">$t</span> = C(<span class="php-quote">'VAR_TEMPLATE'</span>); <span class="php-keyword1">if</span> (<span class="php-keyword1">isset</span>(<span class="php-var">$_GET</span>[<span class="php-var">$t</span>])){ <span class="php-var">$theme</span> = <span class="php-var">$_GET</span>[<span class="php-var">$t</span>]; }<span class="php-keyword1">elseif</span>(cookie(<span class="php-quote">'think_template'</span>)){ <span class="php-var">$theme</span> = cookie(<span class="php-quote">'think_template'</span>); } <span class="php-keyword1">if</span>(!<span class="php-keyword2">in_array</span>(<span class="php-var">$theme</span>,<span class="php-keyword2">explode</span>(<span class="php-quote">','</span>,C(<span class="php-quote">'THEME_LIST'</span>)))){ <span class="php-var">$theme</span> = C(<span class="php-quote">'DEFAULT_THEME'</span>); } cookie(<span class="php-quote">'think_template'</span>,<span class="php-var">$theme</span>,<span class="php-num">864000</span>); } } <span class="php-keyword2">defined</span>(<span class="php-quote">'THEME_NAME'</span>) || <span class="php-keyword2">define</span>(<span class="php-quote">'THEME_NAME'</span>, <span class="php-var">$theme</span>); <span class="php-keyword1">return</span> <span class="php-var">$theme</span>?<span class="php-var">$theme</span> . <span class="php-quote">'/'</span>:<span class="php-quote">''</span>; } }}<span class="php-keyword1">namespace</span> Behavior{ <span class="php-keyword1">class</span> BuildLiteBehavior { <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> run(&amp;<span class="php-var">$params</span>) { <span class="php-keyword1">if</span>(!<span class="php-keyword2">defined</span>(<span class="php-quote">'BUILD_LITE_FILE'</span>)) <span class="php-keyword1">return</span> ; <span class="php-var">$litefile</span> = C(<span class="php-quote">'RUNTIME_LITE_FILE'</span>,<span class="php-keyword1">null</span>,RUNTIME_PATH.<span class="php-quote">'lite.php'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(<span class="php-var">$litefile</span>)) <span class="php-keyword1">return</span>; <span class="php-var">$defs</span> = <span class="php-keyword2">get_defined_constants</span>(<span class="php-keyword1">TRUE</span>); <span class="php-var">$content</span> = <span class="php-quote">'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);'</span>; <span class="php-keyword1">if</span>(MEMORY_LIMIT_ON) { <span class="php-var">$content</span> .= <span class="php-quote">'$GLOBALS[\'_startUseMems\'] = memory_get_usage();'</span>; } <span class="php-keyword1">unset</span>(<span class="php-var">$defs</span>[<span class="php-quote">'user'</span>][<span class="php-quote">'BUILD_LITE_FILE'</span>]); <span class="php-var">$content</span> .= <span class="php-var">$this</span>-&gt;buildArrayDefine(<span class="php-var">$defs</span>[<span class="php-quote">'user'</span>]).<span class="php-quote">'}'</span>; <span class="php-var">$filelist</span> = <span class="php-keyword2">is_file</span>(CONF_PATH.<span class="php-quote">'lite.php'</span>)? <span class="php-keyword1">include</span> CONF_PATH.<span class="php-quote">'lite.php'</span>: <span class="php-keyword1">array</span>( THINK_PATH.<span class="php-quote">'Common/functions.php'</span>, COMMON_PATH.<span class="php-quote">'Common/function.php'</span>, CORE_PATH . <span class="php-quote">'Think'</span>.EXT, CORE_PATH . <span class="php-quote">'Hook'</span>.EXT, CORE_PATH . <span class="php-quote">'App'</span>.EXT, CORE_PATH . <span class="php-quote">'Dispatcher'</span>.EXT, CORE_PATH . <span class="php-quote">'Log'</span>.EXT, CORE_PATH . <span class="php-quote">'Log/Driver/File'</span>.EXT, CORE_PATH . <span class="php-quote">'Route'</span>.EXT, CORE_PATH . <span class="php-quote">'Controller'</span>.EXT, CORE_PATH . <span class="php-quote">'View'</span>.EXT, CORE_PATH . <span class="php-quote">'Storage'</span>.EXT, CORE_PATH . <span class="php-quote">'Storage/Driver/File'</span>.EXT, CORE_PATH . <span class="php-quote">'Exception'</span>.EXT, BEHAVIOR_PATH . <span class="php-quote">'ParseTemplateBehavior'</span>.EXT, BEHAVIOR_PATH . <span class="php-quote">'ContentReplaceBehavior'</span>.EXT, ); <span class="php-keyword1">foreach</span> (<span class="php-var">$filelist</span> <span class="php-keyword1">as</span> <span class="php-var">$file</span>){ <span class="php-keyword1">if</span>(<span class="php-keyword2">is_file</span>(<span class="php-var">$file</span>)) { <span class="php-var">$content</span> .= compile(<span class="php-var">$file</span>); } } <span class="php-var">$content</span> = <span class="php-keyword2">preg_replace</span>(<span class="php-quote">'/\$runtimefile = RUNTIME_PATH(.+?)(if\(APP_STATUS)/'</span>,<span class="php-quote">'\2'</span>,<span class="php-var">$content</span>,<span class="php-num">1</span>); <span class="php-var">$content</span> .= <span class="php-quote">&quot;\nnamespace { Think\Think::addMap(&quot;</span>.<span class="php-keyword2">var_export</span>(\Think\Think::getMap(),<span class="php-keyword1">true</span>).<span class="php-quote">&quot;);&quot;</span>; <span class="php-var">$content</span> .= <span class="php-quote">&quot;\nL(&quot;</span>.<span class="php-keyword2">var_export</span>(L(),<span class="php-keyword1">true</span>).<span class="php-quote">&quot;);\nC(&quot;</span>.<span class="php-keyword2">var_export</span>(C(),<span class="php-keyword1">true</span>).<span class="php-quote">');Think\Hook::import('</span>.<span class="php-keyword2">var_export</span>(\Think\Hook::get(),<span class="php-keyword1">true</span>).<span class="php-quote">');Think\Think::start();}'</span>; <span class="php-keyword2">file_put_contents</span>(<span class="php-var">$litefile</span>,strip_whitespace(<span class="php-quote">'&lt;?php '</span>.<span class="php-var">$content</span>)); } <span class="php-keyword1">private</span> <span class="php-keyword1">function</span> buildArrayDefine(<span class="php-var">$array</span>) { <span class="php-var">$content</span> = <span class="php-quote">&quot;\n&quot;</span>; <span class="php-keyword1">foreach</span> (<span class="php-var">$array</span> <span class="php-keyword1">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$val</span>) { <span class="php-var">$key</span> = <span class="php-keyword2">strtoupper</span>(<span class="php-var">$key</span>); <span class="php-var">$content</span> .= <span class="php-quote">'defined(\''</span> . <span class="php-var">$key</span> . <span class="php-quote">'\') or '</span>; <span class="php-keyword1">if</span> (<span class="php-keyword2">is_int</span>(<span class="php-var">$val</span>) || <span class="php-keyword2">is_float</span>(<span class="php-var">$val</span>)) { <span class="php-var">$content</span> .= <span class="php-quote">&quot;define('&quot;</span> . <span class="php-var">$key</span> . <span class="php-quote">&quot;',&quot;</span> . <span class="php-var">$val</span> . <span class="php-quote">');'</span>; } <span class="php-keyword1">elseif</span> (<span class="php-keyword2">is_bool</span>(<span class="php-var">$val</span>)) { <span class="php-var">$val</span> = (<span class="php-var">$val</span>) ? <span class="php-quote">'true'</span> : <span class="php-quote">'false'</span>; <span class="php-var">$content</span> .= <span class="php-quote">&quot;define('&quot;</span> . <span class="php-var">$key</span> . <span class="php-quote">&quot;',&quot;</span> . <span class="php-var">$val</span> . <span class="php-quote">');'</span>; } <span class="php-keyword1">elseif</span> (<span class="php-keyword2">is_string</span>(<span class="php-var">$val</span>)) { <span class="php-var">$content</span> .= <span class="php-quote">&quot;define('&quot;</span> . <span class="php-var">$key</span> . <span class="php-quote">&quot;','&quot;</span> . <span class="php-keyword2">addslashes</span>(<span class="php-var">$val</span>) . <span class="php-quote">&quot;');&quot;</span>; } <span class="php-var">$content</span> .= <span class="php-quote">&quot;\n&quot;</span>; } <span class="php-keyword1">return</span> <span class="php-var">$content</span>; } }}<span class="php-keyword1">namespace</span> Behavior{ <span class="php-keyword1">use</span> Think\Storage; <span class="php-keyword1">use</span> Think\Think; <span class="php-keyword1">class</span> ParseTemplateBehavior { <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> run(&amp;<span class="php-var">$_data</span>){ <span class="php-var">$engine</span> = <span class="php-keyword2">strtolower</span>(C(<span class="php-quote">'TMPL_ENGINE_TYPE'</span>)); <span class="php-var">$_content</span> = <span class="php-keyword1">empty</span>(<span class="php-var">$_data</span>[<span class="php-quote">'content'</span>])?<span class="php-var">$_data</span>[<span class="php-quote">'file'</span>]:<span class="php-var">$_data</span>[<span class="php-quote">'content'</span>]; <span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>] = !<span class="php-keyword1">empty</span>(<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>])?<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>]:C(<span class="php-quote">'TMPL_CACHE_PREFIX'</span>); <span class="php-keyword1">if</span>(<span class="php-quote">'think'</span>==<span class="php-var">$engine</span>){ <span class="php-keyword1">if</span>((!<span class="php-keyword1">empty</span>(<span class="php-var">$_data</span>[<span class="php-quote">'content'</span>]) &amp;&amp; <span class="php-var">$this</span>-&gt;checkContentCache(<span class="php-var">$_data</span>[<span class="php-quote">'content'</span>],<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>])) || <span class="php-var">$this</span>-&gt;checkCache(<span class="php-var">$_data</span>[<span class="php-quote">'file'</span>],<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>])) { Storage::load(C(<span class="php-quote">'CACHE_PATH'</span>).<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>].<span class="php-keyword2">md5</span>(<span class="php-var">$_content</span>).C(<span class="php-quote">'TMPL_CACHFILE_SUFFIX'</span>),<span class="php-var">$_data</span>[<span class="php-quote">'var'</span>]); }<span class="php-keyword1">else</span>{ <span class="php-var">$tpl</span> = Think::instance(<span class="php-quote">'Think\\Template'</span>); <span class="php-var">$tpl</span>-&gt;fetch(<span class="php-var">$_content</span>,<span class="php-var">$_data</span>[<span class="php-quote">'var'</span>],<span class="php-var">$_data</span>[<span class="php-quote">'prefix'</span>]); } }<span class="php-keyword1">else</span>{ <span class="php-keyword1">if</span>(<span class="php-keyword2">strpos</span>(<span class="php-var">$engine</span>,<span class="php-quote">'\\'</span>)){ <span class="php-var">$class</span> = <span class="php-var">$engine</span>; }<span class="php-keyword1">else</span>{ <span class="php-var">$class</span> = <span class="php-quote">'Think\\Template\\Driver\\'</span>.<span class="php-keyword2">ucwords</span>(<span class="php-var">$engine</span>); } <span class="php-keyword1">if</span>(<span class="php-keyword2">class_exists</span>(<span class="php-var">$class</span>)) { <span class="php-var">$tpl</span> = <span class="php-keyword1">new</span> <span class="php-var">$class</span>; <span class="php-var">$tpl</span>-&gt;fetch(<span class="php-var">$_content</span>,<span class="php-var">$_data</span>[<span class="php-quote">'var'</span>]); }<span class="php-keyword1">else</span> { E(L(<span class="php-quote">'_NOT_SUPPORT_'</span>).<span class="php-quote">': '</span> . <span class="php-var">$class</span>); } } } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> checkCache(<span class="php-var">$tmplTemplateFile</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span> (!C(<span class="php-quote">'TMPL_CACHE_ON'</span>)) <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; <span class="php-var">$tmplCacheFile</span> = C(<span class="php-quote">'CACHE_PATH'</span>).<span class="php-var">$prefix</span>.<span class="php-keyword2">md5</span>(<span class="php-var">$tmplTemplateFile</span>).C(<span class="php-quote">'TMPL_CACHFILE_SUFFIX'</span>); <span class="php-keyword1">if</span>(!Storage::has(<span class="php-var">$tmplCacheFile</span>)){ <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; }<span class="php-keyword1">elseif</span> (<span class="php-keyword2">filemtime</span>(<span class="php-var">$tmplTemplateFile</span>) &gt; Storage::get(<span class="php-var">$tmplCacheFile</span>,<span class="php-quote">'mtime'</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; }<span class="php-keyword1">elseif</span> (C(<span class="php-quote">'TMPL_CACHE_TIME'</span>) != <span class="php-num">0</span> &amp;&amp; <span class="php-keyword2">time</span>() &gt; Storage::get(<span class="php-var">$tmplCacheFile</span>,<span class="php-quote">'mtime'</span>)+C(<span class="php-quote">'TMPL_CACHE_TIME'</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } <span class="php-keyword1">if</span>(C(<span class="php-quote">'LAYOUT_ON'</span>)) { <span class="php-var">$layoutFile</span> = THEME_PATH.C(<span class="php-quote">'LAYOUT_NAME'</span>).C(<span class="php-quote">'TMPL_TEMPLATE_SUFFIX'</span>); <span class="php-keyword1">if</span>(<span class="php-keyword2">filemtime</span>(<span class="php-var">$layoutFile</span>) &gt; Storage::get(<span class="php-var">$tmplCacheFile</span>,<span class="php-quote">'mtime'</span>)) { <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> checkContentCache(<span class="php-var">$tmplContent</span>,<span class="php-var">$prefix</span>=<span class="php-quote">''</span>) { <span class="php-keyword1">if</span>(Storage::has(C(<span class="php-quote">'CACHE_PATH'</span>).<span class="php-var">$prefix</span>.<span class="php-keyword2">md5</span>(<span class="php-var">$tmplContent</span>).C(<span class="php-quote">'TMPL_CACHFILE_SUFFIX'</span>))){ <span class="php-keyword1">return</span> <span class="php-keyword1">true</span>; }<span class="php-keyword1">else</span>{ <span class="php-keyword1">return</span> <span class="php-keyword1">false</span>; } } }}<span class="php-keyword1">namespace</span> Behavior{ <span class="php-keyword1">class</span> ContentReplaceBehavior { <span class="php-keyword1">public</span> <span class="php-keyword1">function</span> run(&amp;<span class="php-var">$content</span>){ <span class="php-var">$content</span> = <span class="php-var">$this</span>-&gt;templateContentReplace(<span class="php-var">$content</span>); } <span class="php-keyword1">protected</span> <span class="php-keyword1">function</span> templateContentReplace(<span class="php-var">$content</span>) { <span class="php-var">$replace</span> = <span class="php-keyword1">array</span>( <span class="php-quote">'__ROOT__'</span> =&gt; __ROOT__, <span class="php-quote">'__APP__'</span> =&gt; __APP__, <span class="php-quote">'__MODULE__'</span> =&gt; __MODULE__, <span class="php-quote">'__ACTION__'</span> =&gt; __ACTION__, <span class="php-quote">'__SELF__'</span> =&gt; <span class="php-keyword2">htmlentities</span>(__SELF__), <span class="php-quote">'__CONTROLLER__'</span>=&gt; __CONTROLLER__, <span class="php-quote">'__URL__'</span> =&gt; __CONTROLLER__, <span class="php-quote">'__PUBLIC__'</span> =&gt; __ROOT__.<span class="php-quote">'/Public'</span>, ); <span class="php-keyword1">if</span>(<span class="php-keyword2">is_array</span>(C(<span class="php-quote">'TMPL_PARSE_STRING'</span>)) ) <span class="php-var">$replace</span> = <span class="php-keyword2">array_merge</span>(<span class="php-var">$replace</span>,C(<span class="php-quote">'TMPL_PARSE_STRING'</span>)); <span class="php-var">$content</span> = <span class="php-keyword2">str_replace</span>(<span class="php-keyword2">array_keys</span>(<span class="php-var">$replace</span>),<span class="php-keyword2">array_values</span>(<span class="php-var">$replace</span>),<span class="php-var">$content</span>); <span class="php-keyword1">return</span> <span class="php-var">$content</span>; } }} <span class="php-keyword1">namespace</span> { Think\Think::addMap(<span class="php-keyword1">array</span> ( <span class="php-quote">'Think\\Log'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Log.class.php'</span>, <span class="php-quote">'Think\\Log\\Driver\\File'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Log/Driver/File.class.php'</span>, <span class="php-quote">'Think\\Exception'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Exception.class.php'</span>, <span class="php-quote">'Think\\Model'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Model.class.php'</span>, <span class="php-quote">'Think\\Db'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Db.class.php'</span>, <span class="php-quote">'Think\\Template'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Template.class.php'</span>, <span class="php-quote">'Think\\Cache'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Cache.class.php'</span>, <span class="php-quote">'Think\\Cache\\Driver\\File'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Cache/Driver/File.class.php'</span>, <span class="php-quote">'Think\\Storage'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP\\Library/Think/Storage.class.php'</span>, )); L(<span class="php-keyword1">array</span> ( <span class="php-quote">'_MODULE_NOT_EXIST_'</span> =&gt; <span class="php-quote">'无法加载模块'</span>, <span class="php-quote">'_CONTROLLER_NOT_EXIST_'</span> =&gt; <span class="php-quote">'无法加载控制器'</span>, <span class="php-quote">'_ERROR_ACTION_'</span> =&gt; <span class="php-quote">'非法操作'</span>, <span class="php-quote">'_LANGUAGE_NOT_LOAD_'</span> =&gt; <span class="php-quote">'无法加载语言包'</span>, <span class="php-quote">'_TEMPLATE_NOT_EXIST_'</span> =&gt; <span class="php-quote">'模板不存在'</span>, <span class="php-quote">'_MODULE_'</span> =&gt; <span class="php-quote">'模块'</span>, <span class="php-quote">'_ACTION_'</span> =&gt; <span class="php-quote">'操作'</span>, <span class="php-quote">'_MODEL_NOT_EXIST_'</span> =&gt; <span class="php-quote">'模型不存在或者没有定义'</span>, <span class="php-quote">'_VALID_ACCESS_'</span> =&gt; <span class="php-quote">'没有权限'</span>, <span class="php-quote">'_XML_TAG_ERROR_'</span> =&gt; <span class="php-quote">'XML标签语法错误'</span>, <span class="php-quote">'_DATA_TYPE_INVALID_'</span> =&gt; <span class="php-quote">'非法数据对象！'</span>, <span class="php-quote">'_OPERATION_WRONG_'</span> =&gt; <span class="php-quote">'操作出现错误'</span>, <span class="php-quote">'_NOT_LOAD_DB_'</span> =&gt; <span class="php-quote">'无法加载数据库'</span>, <span class="php-quote">'_NO_DB_DRIVER_'</span> =&gt; <span class="php-quote">'无法加载数据库驱动'</span>, <span class="php-quote">'_NOT_SUPPORT_DB_'</span> =&gt; <span class="php-quote">'系统暂时不支持数据库'</span>, <span class="php-quote">'_NO_DB_CONFIG_'</span> =&gt; <span class="php-quote">'没有定义数据库配置'</span>, <span class="php-quote">'_NOT_SUPPORT_'</span> =&gt; <span class="php-quote">'系统不支持'</span>, <span class="php-quote">'_CACHE_TYPE_INVALID_'</span> =&gt; <span class="php-quote">'无法加载缓存类型'</span>, <span class="php-quote">'_FILE_NOT_WRITABLE_'</span> =&gt; <span class="php-quote">'目录（文件）不可写'</span>, <span class="php-quote">'_METHOD_NOT_EXIST_'</span> =&gt; <span class="php-quote">'方法不存在！'</span>, <span class="php-quote">'_CLASS_NOT_EXIST_'</span> =&gt; <span class="php-quote">'实例化一个不存在的类！'</span>, <span class="php-quote">'_CLASS_CONFLICT_'</span> =&gt; <span class="php-quote">'类名冲突'</span>, <span class="php-quote">'_TEMPLATE_ERROR_'</span> =&gt; <span class="php-quote">'模板引擎错误'</span>, <span class="php-quote">'_CACHE_WRITE_ERROR_'</span> =&gt; <span class="php-quote">'缓存文件写入失败！'</span>, <span class="php-quote">'_TAGLIB_NOT_EXIST_'</span> =&gt; <span class="php-quote">'标签库未定义'</span>, <span class="php-quote">'_OPERATION_FAIL_'</span> =&gt; <span class="php-quote">'操作失败！'</span>, <span class="php-quote">'_OPERATION_SUCCESS_'</span> =&gt; <span class="php-quote">'操作成功！'</span>, <span class="php-quote">'_SELECT_NOT_EXIST_'</span> =&gt; <span class="php-quote">'记录不存在！'</span>, <span class="php-quote">'_EXPRESS_ERROR_'</span> =&gt; <span class="php-quote">'表达式错误'</span>, <span class="php-quote">'_TOKEN_ERROR_'</span> =&gt; <span class="php-quote">'表单令牌错误'</span>, <span class="php-quote">'_RECORD_HAS_UPDATE_'</span> =&gt; <span class="php-quote">'记录已经更新'</span>, <span class="php-quote">'_NOT_ALLOW_PHP_'</span> =&gt; <span class="php-quote">'模板禁用PHP代码'</span>, <span class="php-quote">'_PARAM_ERROR_'</span> =&gt; <span class="php-quote">'参数错误或者未定义'</span>, <span class="php-quote">'_ERROR_QUERY_EXPRESS_'</span> =&gt; <span class="php-quote">'错误的查询条件'</span>, )); C(<span class="php-keyword1">array</span> ( <span class="php-quote">'APP_USE_NAMESPACE'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'APP_SUB_DOMAIN_DEPLOY'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'APP_SUB_DOMAIN_RULES'</span> =&gt; <span class="php-keyword1">array</span> ( ), <span class="php-quote">'APP_DOMAIN_SUFFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'ACTION_SUFFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'MULTI_MODULE'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'MODULE_DENY_LIST'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Common'</span>, <span class="php-num">1</span> =&gt; <span class="php-quote">'Runtime'</span>, ), <span class="php-quote">'CONTROLLER_LEVEL'</span> =&gt; <span class="php-num">1</span>, <span class="php-quote">'APP_AUTOLOAD_LAYER'</span> =&gt; <span class="php-quote">'Controller,Model'</span>, <span class="php-quote">'APP_AUTOLOAD_PATH'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'COOKIE_EXPIRE'</span> =&gt; <span class="php-num">0</span>, <span class="php-quote">'COOKIE_DOMAIN'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'COOKIE_PATH'</span> =&gt; <span class="php-quote">'/'</span>, <span class="php-quote">'COOKIE_PREFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'COOKIE_SECURE'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'COOKIE_HTTPONLY'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DEFAULT_M_LAYER'</span> =&gt; <span class="php-quote">'Model'</span>, <span class="php-quote">'DEFAULT_C_LAYER'</span> =&gt; <span class="php-quote">'Controller'</span>, <span class="php-quote">'DEFAULT_V_LAYER'</span> =&gt; <span class="php-quote">'View'</span>, <span class="php-quote">'DEFAULT_LANG'</span> =&gt; <span class="php-quote">'zh-cn'</span>, <span class="php-quote">'DEFAULT_THEME'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DEFAULT_MODULE'</span> =&gt; <span class="php-quote">'Home'</span>, <span class="php-quote">'DEFAULT_CONTROLLER'</span> =&gt; <span class="php-quote">'Index'</span>, <span class="php-quote">'DEFAULT_ACTION'</span> =&gt; <span class="php-quote">'index'</span>, <span class="php-quote">'DEFAULT_CHARSET'</span> =&gt; <span class="php-quote">'utf-8'</span>, <span class="php-quote">'DEFAULT_TIMEZONE'</span> =&gt; <span class="php-quote">'PRC'</span>, <span class="php-quote">'DEFAULT_AJAX_RETURN'</span> =&gt; <span class="php-quote">'JSON'</span>, <span class="php-quote">'DEFAULT_JSONP_HANDLER'</span> =&gt; <span class="php-quote">'jsonpReturn'</span>, <span class="php-quote">'DEFAULT_FILTER'</span> =&gt; <span class="php-quote">'htmlspecialchars'</span>, <span class="php-quote">'DB_TYPE'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_HOST'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_NAME'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_USER'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_PWD'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_PORT'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_PREFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DB_PARAMS'</span> =&gt; <span class="php-keyword1">array</span> ( ), <span class="php-quote">'DB_DEBUG'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'DB_FIELDS_CACHE'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'DB_CHARSET'</span> =&gt; <span class="php-quote">'utf8'</span>, <span class="php-quote">'DB_DEPLOY_TYPE'</span> =&gt; <span class="php-num">0</span>, <span class="php-quote">'DB_RW_SEPARATE'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'DB_MASTER_NUM'</span> =&gt; <span class="php-num">1</span>, <span class="php-quote">'DB_SLAVE_NO'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DATA_CACHE_TIME'</span> =&gt; <span class="php-num">0</span>, <span class="php-quote">'DATA_CACHE_COMPRESS'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'DATA_CACHE_CHECK'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'DATA_CACHE_PREFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DATA_CACHE_TYPE'</span> =&gt; <span class="php-quote">'File'</span>, <span class="php-quote">'DATA_CACHE_PATH'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\Application\\Test/../Application/Runtime/Temp/'</span>, <span class="php-quote">'DATA_CACHE_KEY'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'DATA_CACHE_SUBDIR'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'DATA_PATH_LEVEL'</span> =&gt; <span class="php-num">1</span>, <span class="php-quote">'ERROR_MESSAGE'</span> =&gt; <span class="php-quote">'页面错误！请稍后再试～'</span>, <span class="php-quote">'ERROR_PAGE'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'SHOW_ERROR_MSG'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'TRACE_MAX_RECORD'</span> =&gt; <span class="php-num">100</span>, <span class="php-quote">'LOG_RECORD'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'LOG_TYPE'</span> =&gt; <span class="php-quote">'File'</span>, <span class="php-quote">'LOG_LEVEL'</span> =&gt; <span class="php-quote">'EMERG,ALERT,CRIT,ERR'</span>, <span class="php-quote">'LOG_FILE_SIZE'</span> =&gt; <span class="php-num">2097152</span>, <span class="php-quote">'LOG_EXCEPTION_RECORD'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'SESSION_AUTO_START'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'SESSION_OPTIONS'</span> =&gt; <span class="php-keyword1">array</span> ( ), <span class="php-quote">'SESSION_TYPE'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'SESSION_PREFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'TMPL_CONTENT_TYPE'</span> =&gt; <span class="php-quote">'text/html'</span>, <span class="php-quote">'TMPL_ACTION_ERROR'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP/Tpl/dispatch_jump.tpl'</span>, <span class="php-quote">'TMPL_ACTION_SUCCESS'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP/Tpl/dispatch_jump.tpl'</span>, <span class="php-quote">'TMPL_EXCEPTION_FILE'</span> =&gt; <span class="php-quote">'C:\\xampp\\htdocs\\xy\\ThinkPHP/Tpl/think_exception.tpl'</span>, <span class="php-quote">'TMPL_DETECT_THEME'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'TMPL_TEMPLATE_SUFFIX'</span> =&gt; <span class="php-quote">'.html'</span>, <span class="php-quote">'TMPL_FILE_DEPR'</span> =&gt; <span class="php-quote">'/'</span>, <span class="php-quote">'TMPL_ENGINE_TYPE'</span> =&gt; <span class="php-quote">'Think'</span>, <span class="php-quote">'TMPL_CACHFILE_SUFFIX'</span> =&gt; <span class="php-quote">'.php'</span>, <span class="php-quote">'TMPL_DENY_FUNC_LIST'</span> =&gt; <span class="php-quote">'echo,exit'</span>, <span class="php-quote">'TMPL_DENY_PHP'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'TMPL_L_DELIM'</span> =&gt; <span class="php-quote">'{'</span>, <span class="php-quote">'TMPL_R_DELIM'</span> =&gt; <span class="php-quote">'}'</span>, <span class="php-quote">'TMPL_VAR_IDENTIFY'</span> =&gt; <span class="php-quote">'array'</span>, <span class="php-quote">'TMPL_STRIP_SPACE'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'TMPL_CACHE_ON'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'TMPL_CACHE_PREFIX'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'TMPL_CACHE_TIME'</span> =&gt; <span class="php-num">0</span>, <span class="php-quote">'TMPL_LAYOUT_ITEM'</span> =&gt; <span class="php-quote">'{__CONTENT__}'</span>, <span class="php-quote">'LAYOUT_ON'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'LAYOUT_NAME'</span> =&gt; <span class="php-quote">'layout'</span>, <span class="php-quote">'TAGLIB_BEGIN'</span> =&gt; <span class="php-quote">'&lt;'</span>, <span class="php-quote">'TAGLIB_END'</span> =&gt; <span class="php-quote">'&gt;'</span>, <span class="php-quote">'TAGLIB_LOAD'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'TAGLIB_BUILD_IN'</span> =&gt; <span class="php-quote">'cx'</span>, <span class="php-quote">'TAGLIB_PRE_LOAD'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'URL_CASE_INSENSITIVE'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'URL_MODEL'</span> =&gt; <span class="php-num">1</span>, <span class="php-quote">'URL_PATHINFO_DEPR'</span> =&gt; <span class="php-quote">'/'</span>, <span class="php-quote">'URL_PATHINFO_FETCH'</span> =&gt; <span class="php-quote">'ORIG_PATH_INFO,REDIRECT_PATH_INFO,REDIRECT_URL'</span>, <span class="php-quote">'URL_REQUEST_URI'</span> =&gt; <span class="php-quote">'REQUEST_URI'</span>, <span class="php-quote">'URL_HTML_SUFFIX'</span> =&gt; <span class="php-quote">'html'</span>, <span class="php-quote">'URL_DENY_SUFFIX'</span> =&gt; <span class="php-quote">'ico|png|gif|jpg'</span>, <span class="php-quote">'URL_PARAMS_BIND'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'URL_PARAMS_BIND_TYPE'</span> =&gt; <span class="php-num">0</span>, <span class="php-quote">'URL_PARAMS_FILTER'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'URL_PARAMS_FILTER_TYPE'</span> =&gt; <span class="php-quote">''</span>, <span class="php-quote">'URL_ROUTER_ON'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'URL_ROUTE_RULES'</span> =&gt; <span class="php-keyword1">array</span> ( ), <span class="php-quote">'URL_MAP_RULES'</span> =&gt; <span class="php-keyword1">array</span> ( ), <span class="php-quote">'VAR_MODULE'</span> =&gt; <span class="php-quote">'m'</span>, <span class="php-quote">'VAR_ADDON'</span> =&gt; <span class="php-quote">'addon'</span>, <span class="php-quote">'VAR_CONTROLLER'</span> =&gt; <span class="php-quote">'c'</span>, <span class="php-quote">'VAR_ACTION'</span> =&gt; <span class="php-quote">'a'</span>, <span class="php-quote">'VAR_AJAX_SUBMIT'</span> =&gt; <span class="php-quote">'ajax'</span>, <span class="php-quote">'VAR_JSONP_HANDLER'</span> =&gt; <span class="php-quote">'callback'</span>, <span class="php-quote">'VAR_PATHINFO'</span> =&gt; <span class="php-quote">'s'</span>, <span class="php-quote">'VAR_TEMPLATE'</span> =&gt; <span class="php-quote">'t'</span>, <span class="php-quote">'VAR_AUTO_STRING'</span> =&gt; <span class="php-keyword1">false</span>, <span class="php-quote">'HTTP_CACHE_CONTROL'</span> =&gt; <span class="php-quote">'private'</span>, <span class="php-quote">'CHECK_APP_DIR'</span> =&gt; <span class="php-keyword1">true</span>, <span class="php-quote">'FILE_UPLOAD_TYPE'</span> =&gt; <span class="php-quote">'Local'</span>, <span class="php-quote">'DATA_CRYPT_TYPE'</span> =&gt; <span class="php-quote">'Think'</span>, ));Think\Hook::import(<span class="php-keyword1">array</span> ( <span class="php-quote">'app_init'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\BuildLiteBehavior'</span>, ), <span class="php-quote">'app_begin'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\ReadHtmlCacheBehavior'</span>, ), <span class="php-quote">'app_end'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\ShowPageTraceBehavior'</span>, ), <span class="php-quote">'view_parse'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\ParseTemplateBehavior'</span>, ), <span class="php-quote">'template_filter'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\ContentReplaceBehavior'</span>, ), <span class="php-quote">'view_filter'</span> =&gt; <span class="php-keyword1">array</span> ( <span class="php-num">0</span> =&gt; <span class="php-quote">'Behavior\\WriteHtmlCacheBehavior'</span>, ), ));}</span></code></pre>

	<div id="footer">
		XY Server API alpha API documentation generated by <a href="http://apigen.org">ApiGen</a>
	</div>
</div>
</div>
<script src="resources/combined.js?e1238c180c0ec4879c106550549125735c31011b"></script>
<script src="elementlist.js?65b96360bff0d94f47f8799f2472e5eeb7655dd9"></script>
</body>
</html>
